Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求助牛人,为什么我的这段代码用G++提交可以AC,但是用C++提交却是RE,哪位大哥解答一下,小弟不胜感激代码如下: #include <iostream> #include <string> using namespace std; int main() { string str; int i,j,p; cin>>str; while(str!="-1") { p=-1; string v[17]; v[0]=str; for(i=0; i<15; i++) { string temp(""); char count[10]={0}; for(j=0;j<str.length();j++) count[str[j]-'0']++; for(j=9; j>=0; j--) { if(int(count[j])) { temp.insert(temp.begin(),char(j+'0')); if(count[j]>9) { temp.insert(temp.begin(),char(count[j]%10+'0')); temp.insert(temp.begin(),char(count[j]/10+'0')); } else temp.insert(temp.begin(),char(count[j]+'0')); } } str = temp; for(j=i; j>=0; j--) { if(temp == v[j]) { p = j; goto loop; } } v[i+1] = str; } loop: if(i==0 && p==i) cout<<v[0]<<" is self-inventorying\n"; else if(v[p]==str && i>p) cout<<v[0]<<" enters an inventory loop of length " <<i-p+1<<endl; else if(i==p && i!=0) cout<<v[0]<<" is self-inventorying after "<<i<<" steps\n"; else if(p==-1) cout<<v[0]<<" can not be classified after 15 iterations\n"; cin>>str; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator