string版题解
2025-07-29 09:19:30
发布于:广东
2阅读
0回复
0点赞
这种题用string做最方便,不用考虑long long
#include<bits/stdc++.h>
using namespace std;
int main(){
string a;
cin>>a;
for(int i=a.size()-1;i>=0;i--){ //从字符串最后遍历到前面
cout<<a[i];
}
return 0;
}
全部评论 1
有没有一种可能你可以这样
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
while(n>0)
{
cout<<n%10;
n/=10;
}
return 0;
}3天前 来自 上海
0
有帮助,赞一个