不知道哪里有问题。。
查看原帖
不知道哪里有问题。。
505484
冬笙夏洛_楼主2021/8/21 17:37
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	string str; cin >> str;
	int n = str.size() - 1;
	//如果数字是 0
	if (n == 0 && str[0] == '0') {
		cout << 0 << endl; return 0;
	}
	//先去掉 后置0
	while (str[n] == '0') {
		str[n] = '\0';
		n--;
	}
	//有 负号就保留负号
	if (str[0] == '-')reverse(str.begin() + 1, str.end());
	else reverse(str.begin(), str.end());
	cout << str << endl;

	return 0;
}
2021/8/21 17:37
加载中...