洛谷真是个好地方,经常学到新东西,嘻嘻。
while (x) {
t = t * 10 + x % 10;
x = x / 10;
}
会把整数x反转过来
#include<iostream>
using namespace std;
int main()
{
int x,t=0;
cin >> x;
while (x) {
t = t * 10 + x % 10;
x = x / 10;
}
cout << t;
return 0;
}