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 |
跪求大牛们帮我看下我这个程序出错在哪里?数据在本地都通的过,一上去就wa.#include<iostream> #include<string> //#include<cstring> #include<memory.h> using namespace std; char weigh[6][7]; string word[3]; int signal[12]; int main() { int j,length,n,k; cin>>n; while(n--) { memset(weigh,0,42); for(j=0;j<12;j++) signal[j]=3; for(j=0;j<5;j+=2) cin>>weigh[j]>>weigh[j+1]>>word[j/2]; for(j=0;j<5;j+=2) { length=strlen(weigh[j]); if(word[j/2]=="even") for(k=0;k<length;k++) signal[weigh[j][k]-'A']=signal[weigh[j+1][k]-'A']=0; else if(word[j/2]=="up") { for(k=0;k<length;k++) { if((signal[weigh[j][k]-'A']==2)||(signal[weigh[j][k]-'A']==3)) { signal[weigh[j][k]-'A']=2; } else { signal[weigh[j][k]-'A']=0; } if((signal[weigh[j+1][k]-'A']==1)||(signal[weigh[j+1][k]-'A']==3)) { signal[weigh[j+1][k]-'A']=1; } else { signal[weigh[j+1][k]-'A']=0; } } } else if(word[j/2]=="down") { for(k=0;k<length;k++) { if((signal[weigh[j][k]-'A']==1)||(signal[weigh[j][k]-'A']==3)) { signal[weigh[j][k]-'A']=1; } else { signal[weigh[j][k]-'A']=0; } if((signal[weigh[j+1][k]-'A']==2)||(signal[weigh[j+1][k]-'A']==3)) { signal[weigh[j+1][k]-'A']=2; } else { signal[weigh[j+1][k]-'A']=0; } } } else ; } for(k=0;k<12;k++) { if(signal[k]==1) { cout<<char('A'+k)<<" is the counterfeit coin and it is light."<<endl; break; } else if (signal[k]==2) { cout<<char('A'+k)<<" is the counterfeit coin and it is heavy."<<endl; break; } } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator