70 tps wa字符串求调(悬棺)
查看原帖
70 tps wa字符串求调(悬棺)
825829
F__K_z楼主2024/8/22 21:55
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string a;
	cin >> a;
	if (a[0] == '-') {
		reverse(a.begin(), a.end());
		cout << "-";
		for (int i = 1; i <= a.size() - 1; i++) {
			if((a[i] == '0' && a[i - 1] == 0) || (i == 1 && a[i] == '0') || a[i] == '-'){
				continue;
			}
			else cout << a[i];
		}
	}
	else {
		reverse(a.begin(), a.end());
		for (int i = 0; i <= a.size() - 1; i++) {
			if((a[i] == '0' && a[i - 1] == 0) || (i == 0 && a[i] == '0')){
				continue;
			}
			else cout << a[i];
		}
	}
	return 0;
}

2024/8/22 21:55
加载中...