7个点WA!!!
#include <bits/stdc++.h>
using namespace std;
/*
Type | do
0 | 整数反转
1 | 小数反转
2 | 分数反转
3 | 百分数反转
*/
string s;
int Type = 0;
int tmpi = 0,I;
vector <char> tmp1, tmp2;
int main () {
Type = 0;
cin >> s;
int len = s.length();
for (int i = 0; i < len; i++) {
if (s[i] == '.') {
Type = 1;
tmpi = i;
break;
}
if (s[i] == '/') {
Type = 2;
tmpi = i;
break;
}
if (s[i] == '%') {
Type = 3;
tmpi = i;
break;
}
tmp1.push_back(s[i]);
}
if (Type == 0) {
reverse(tmp1.begin(), tmp1.end());
I = 0;
while(tmp1[I] == '0'){
tmp1[I] = '|';
I++;
}
for (int i = 0; i < tmp1.size(); i++) {
if(tmp1[i] == '|') continue;
cout << tmp1[i];
}
}
if (Type == 1) {
for (int i = tmpi + 1; i < len; i++){
tmp2.push_back(s[i]);
}
I = 0;
while(tmp2[I] == '0'){
tmp2[I] = '|';
I++;
}
reverse(tmp1.begin(), tmp1.end());
reverse(tmp2.begin(), tmp2.end());
I = 0;
while(tmp1[I] == '0'){
tmp1[I] = '|';
I++;
}
for (int i = 0; i < tmp1.size(); i++) {
if(tmp1[i] == '|') continue;
cout << tmp1[i];
}
cout << '.';
for (int i = 0; i < tmp2.size(); i++) {
if(tmp2[i] == '|') continue;
cout << tmp2[i];
}
}
if (Type == 2) {
for (int i = tmpi + 1; i < len; i++){
tmp2.push_back(s[i]);
}
I = 0;
while(tmp2[I] == '0'){
tmp2[I] = '|';
I++;
}
reverse(tmp1.begin(), tmp1.end());
reverse(tmp2.begin(), tmp2.end());
I = 0;
while(tmp1[I] == '0'){
tmp1[I] = '|';
I++;
}
for (int i = 0; i < tmp1.size(); i++) {
if(tmp1[i] == '|') continue;
cout << tmp1[i];
}
cout << '/';
for (int i = 0; i < tmp2.size(); i++) {
if(tmp2[i] == '|') continue;
cout << tmp2[i];
}
}
if (Type == 3) {
reverse(tmp1.begin(), tmp1.end());
I = 0;
while(tmp1[I] == '0'){
tmp1[I] = '|';
I++;
}
for (int i = 0; i < tmp1.size(); i++) {
if(tmp1[i] == '|') continue;
cout << tmp1[i];
}
cout << '%';
}
return 0;
}
求助大佬!!