0
Is there a way to simplify this code?
The code has to "reflex" given number. In example: 1234 to 4321. https://code.sololearn.com/cSzV7xo7XzFi/?ref=app
1 Odpowiedź
+ 4
#include <iostream>
using namespace std;
int reverse(int);
int main() {
int n;
cin >> n;
cout << reverse(n);
return 0;
}
int reverse(int n) {
int x=0;
while (n > 0){
x=(x*10)+(n%10);
n=n/10;
}
return x;
}