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 <algorithm> using namespace std; struct words { char word[50],word2[50]; words *next; }; words *dic_first; void dic_creat() { char w1[50]; words *p1,*p2; dic_first=new words; p1=dic_first; cin>>w1; while(strcmp(w1,"XXXXXX")){ p2=new words; strcpy(p2->word,w1); sort(w1,w1+strlen(w1)); strcpy(p2->word2,w1); p1->next=p2; p1=p2; cin>>w1; } p1->next=NULL; } void display(char *str) { char str1[50]; strcpy(str1,str); int i=0; words *d1; d1=dic_first->next; while(d1!=NULL){ strcpy(str,str1); if(!strcmp(d1->word2,str)){ i=1; cout<<d1->word<<endl; d1=d1->next; continue; } else d1=d1->next; } if(i==0) cout<<"NOT A VALID WORD"<<endl; cout<<"******"<<endl; } int main() { char str[50]; dic_creat(); cin>>str; while(strcmp(str,"XXXXXX")){ sort(str,str+strlen(str)); display(str); cin>>str; } system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator