#include<iostream>#include<cstring>#include<algorithm>usingnamespace std;intmain(){int x;
cin >> x;bool flag =false;if(x <0) x =-x, flag =true;int ans =0;while(x){
ans = ans *10+ x %10;
x /=10;}if(flag) cout <<"-";
cout << ans;return0;}
题目Acwing 445. 数字反转代码#include <iostream>#include <cstring>#include <algorithm>using namespace std;int main(){ int x; cin >> x; bool flag = false; if (x < 0) x = -x, flag = true; int ans = 0;