求助各位,一直是20分

P1553 数字反转(升级版)

@[shenshen](/space/show?uid=150593) 帮你改了一下。 ```cpp #include <iostream> #include <cstdio> #include <stack> using namespace std; int main() { char a; a=getchar(); char e; int flag=1; stack <char> L; bool dt=false; string str; while(a!=EOF) { if(a>='0'&&a<='9') { L.push(a); } else if(a=='.'||a=='/') { if(a=='.')dt=true; while(!L.empty()) { if(L.size()>1 && flag==1 && (e=L.top())=='0') { L.pop(); } else { e=L.top(); L.pop(); str=str+e; flag=0; } } str=str+a; } else if(a=='%') { while(!L.empty()) { if(L.size()>1 && flag==1 && (e=L.top())=='0') { L.pop(); } else { e=L.top(); L.pop(); str=str+e; flag=0; } } str=str+a; cout<<str<<endl; return 0; } a=getchar(); } if(a==EOF) { flag=1; while(!L.empty()) { if(L.size()>1 && flag==1 && (e=L.top())=='0') { L.pop(); } else { e=L.top(); L.pop(); str=str+e; flag=0; } } } if(str.find('.')!=string::npos)while(*str.rbegin()=='0' && str[str.size()-2]!='.')str.erase(--str.end()); cout<<str<<endl; } ```
by Smile_Cindy @ 2019-05-01 17:49:02


@[Alpha](/space/show?uid=87058) 请问一下,为什么我的代码会提交不过呢?
by JC_Apink @ 2019-05-20 22:43:16


|