50分求助
查看原帖
50分求助
711037
NNFeNN楼主2023/5/30 20:48
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()  {
	cin>>a;
	int j=0;
	if(a[0]=='-'){
		for(int i=a.size()-1;i>=1;i--,j++) {
		b=b+a[i];
		}
		if(b[0]=='0') {
		b.erase(0,b.find_first_not_of('0'));
		}
		cout<<'-'<<b<<endl;
	}
	else{
		for(int i=a.size()-1;i>=1;i--,j++) {
			b=b+a[i];
			}
			if(b[0]=='0') {
			b.erase(0,b.find_first_not_of('0'));
			}
			cout<<b<<endl;	
	}
    return 0;
}
2023/5/30 20:48
加载中...