60pts玄关求调
查看原帖
60pts玄关求调
1383405
Leonardo20142楼主2025/8/3 11:10
#include<bits/stdc++.h>
using namespace std;
int main() {
	string a;
	cin >> a;
	if (a.find('.') != a.npos) {
		int t = a.find('.');
		string x = a.substr(0, t - 0);
		string y = a.substr(t + 1);
		reverse(x.begin(), x.end());
		reverse(y.begin(), y.end());
		a = x + "." + y;
		cout << stod(a);
	} else if (a.find('/') != a.npos) {
		int t = a.find('/');
		string x = a.substr(0, t - 0);
		string y = a.substr(t + 1);
		reverse(x.begin(), x.end());
		reverse(y.begin(), y.end());
		long long x1 = stoll(x);
		long long x2 = stoll(y);
		cout << x1 << '/' << x2;
	} else if (a[a.size() - 1] == '%') {
		string x = a.substr(0, a.size() - 1);
		reverse(x.begin(), x.end());
		long long y = stoll(x);
		cout << y << '%';
	} else {
		reverse(a.begin(), a.end());
		cout<<a;
	}
	return 0;
}

2025/8/3 11:10
加载中...