就一错的,咋办?
查看原帖
就一错的,咋办?
922691
Hisy楼主2023/6/22 21:13
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string str;
bool flag=1;
int main(){
	cin>>str;
	if(str[0]=='-'){
		cout<<"-";
		str.erase(0,1);
	};
	reverse(str.begin(),str.end());
	for(int i=0;i<str.size();i++){
		if(str[i]!='0'){
			flag=0;
		};
		if(!(str[i]=='0'&&flag)){
			cout<<str[i];
		};
	};
	return 0;
};
2023/6/22 21:13
加载中...