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?(附代码)。那位高手帮忙修正后,发到jianfengwen◎163.com中。拜托!!!#include<iostream> #include<string> using namespace std; #define max 10001 string w[max]; string result[max][551]; void deal(string w[],int c,string wt[],int ct) { int count; int flag; for(int i=0;i<ct;i++) { flag=0; count=0; for(int j=0;j<c;j++) { if(wt[i].length()==w[j].length()) { if(wt[i]==w[j]) { //equal flag=1; result[i][0]="is corrent"; result[i][1]="*"; break; } else { //replace int q=0,k=0; while(q<w[j].length()) { if(w[j].substr(q,1)!=wt[i].substr(q,1)) { k++; } if(k>1) { break; } q++; } if(k==1) { result[i][count++]=w[j]; } } } else if(wt[i].length()==w[j].length()+1) { // delete int p=0,q=0,k=0; string str; while(p<wt[i].length()) { if(w[j].substr(q,1)!=wt[i].substr(p,1)) { if(p==0) { str=wt[i].substr(1,wt[i].length()-1); } else if(p==wt[i].length()-1) { str=wt[i].substr(0,wt[i].length()-1); } else { str=wt[i].substr(0,p)+wt[i].substr(p+1,wt[i].length()-p); } if(w[j]==str) { result[i][count++]=w[j]; } else break; } p++;q++; } } else if(wt[i].length()==w[j].length()-1) { // insert int q=0,p=0,k=0; string str; while(q<w[j].length()) { if(w[j].substr(q,1)!=wt[i].substr(p,1)) { if(q==0) { str=w[j].substr(1,w[j].length()-1); } else if(q==w[j].length()-1) { str=w[j].substr(0,w[j].length()-1); } else { str=w[j].substr(0,q)+w[j].substr(q+1,w[j].length()-q); } if(wt[i]==str) { result[i][count++]=w[j]; } else break; } p++;q++; } } } if(flag==0) result[i][count++]="*"; } int t=0; //output for(int j=0;j<ct;j++) { cout<<wt[j]; if(result[t][0]!="is corrent") cout<<": "; else cout<<" "; for(int i=0;i<550;i++) { if(result[j][i]!="*") { cout<<result[j][i]<<" "; } else break; } t++; cout<<endl; } } void main() { string wt[max]; string s1,s2; int c=0,ct=0; cin>>s1; while(s1!="#") { w[c++]=s1; cin>>s1; } while(true) { cin>>s2; if(s2!="#") wt[ct++]=s2; else break; } deal(w,c,wt,ct); ct=0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator