Given a 32-bit signed integer, reverse digits of an integer.
Example 1:
Input: 123 Output: 321 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.
利用取余数的性质。
高中物理有提到过控制电路的几个方法:光敏电阻、压感电阻、按钮、旋转器等等。Arduino也比较类似。
const int analogPin = A0;//the analog input pin attach to
const int ledPin = 9;//the led attach to
int inputValue = 0;//variable to store the value coming from sensor
int outputValue = 0;//variable to store the output value
void setup()
{
}
void loop()
{
inputValue = analogRead(analogPin);//read the value from the sensor
outputValue = map(inputValue,0,1023,0,255);//Convert from 0-1023 proportional to the number of a number of from 0 to 255
analogWrite(ledPin,outputValue);//turn the led on depend on the output value
}
Arduino是一款便捷灵活、方便上手的开源电子原型平台。包含硬件(各种型号的Arduino板)和软件(Arduino IDE)。本质上,Arduino板是一块控制器,并且需要Arduino语言来操控。为了简化编程过程,语言界面甚至连主函数都不需要(似乎库用的是cpp文件)。
Given a non-empty array of digits representing a non-negative integer, plus one to the integer.
The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a single digit.
You may assume the integer does not contain any leading zero, except the number 0 itself.
Example 1:
Input: [1,2,3] Output: [1,2,4] Explanation: The array represents the integer 123.
LeetCode是个好地方。这个系列会把LeetCode-探索-初级算法中的一些题目挑出来,并附上答案。没有什么值得讲解必要的题目将被忽略。出于大人的原因,代码的形式是java。不定期更新。