Created
March 9, 2020 09:16
-
-
Save TokisakiKurumi2001/65c77a1d7a626affc676f242dbc45ed4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void setup() { | |
| // put your setup code here, to run once: | |
| Serial.begin(9600); | |
| } | |
| void loop() { | |
| // put your main code here, to run repeatedly: | |
| int number, res; | |
| String c; | |
| if (Serial.available()) | |
| { | |
| c = Serial.readString(); | |
| number = c.toInt(); | |
| res = reverse_num(number); | |
| Serial.println(res); | |
| } | |
| } | |
| int reverse_num(int num) | |
| { | |
| int digit = 0; | |
| int new_num = 0; | |
| while (num != 0) | |
| { | |
| digit = num % 10; | |
| new_num = new_num * 10 + digit; | |
| num /= 10; | |
| } | |
| return new_num; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment