yimingwang @ 2023-12-13 12:11:32
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,a2=0,b;
cin>>a;
while(a>0)
{
b=a%10;
a2=a2*10+b;
a=a/10;
}
cout<<a2<<endl;
return 0;
}
by chenyuchen_1 @ 2023-12-13 12:48:24
@yimingwang 这么有信心?样例都不测就干提交?
by _IOI_THANKFUL @ 2023-12-13 12:58:16
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,a2=0,b;
cin>>a;
while(a>0)
{
b=a%10;
a2=a2*10+b;
a=a/10;
}
cout<<a2<<endl;
return 0;
}
by _IOI_THANKFUL @ 2023-12-13 12:58:25
@yimingwang
by xiaoshumiao @ 2023-12-13 13:08:24
@yimingwang 你没考虑复数的情况。
by xiaoshumiao @ 2023-12-13 13:08:44
负数,手滑。
by chen__pengyu @ 2023-12-17 15:49:39
#include<iostream>
using namespace std;
int main(){
int n,a,b=0;
cin>>n;
while(n!=0){
a=n%10;
n=(n-a)/10;
b=10*b+a;
}
cout<<b;
return 0;
}
供参考
by ZiruiLIU @ 2024-01-13 13:43:49
@yimingwang 负数 特判0
by ZiruiLIU @ 2024-01-13 14:01:55
@yimingwang 参考代码
#include<bits/stdc++.h>
using namespace std;
int main() {
int n, a, b = 0;
cin >> n;
if (n > 0) {
while (n) {
a = n % 10;
n /= 10;
if (b == 0) {
if (a == 0) {
// b = 1;
continue;
}
else{
b=1;
}
}
cout << a;
}
} else {
if (n == 0) {
cout << 0;
} else {
cout << "-";
n = abs(n);
while (n) {
a = n % 10;
n /= 10;
if (b == 0) {
if (a == 0) {
// b = 1;
continue;
}
else{
b=1;
}
}
cout << a;
}
}
}
return 0;
}