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 |
又要注意什么啊??我觉得没错阿???#include<stdio.h> #include<stdlib.h> #include<string.h> #define MAX 100 char dic[MAX+1][7];//如果是6 会使前后两个单词联起来!! char word[6]; int nd; int cmp(const void *a, const void *b) { char *x=(char *)a; char *y=(char *)b; return strcmp(x,y); } void init() { int i=0; while(1) { gets(dic[i]); if(!strcmp("XXXXXX",dic[i])) break; i++; } nd=i; qsort(dic,nd,7,cmp); } int unscramble(char a[],char b[]) { int i,j,flag,len; char buffer[7]; char temp[6]; strcpy(temp,b); len=strlen(a); if(len!=strlen(b)) flag=0; else { for(i=0;i<len;i++) buffer[i]='*'; buffer[len]=0; for(i=0;i<len;i++) for(j=0;j<len;j++) if(a[i]==temp[j]) temp[j]='*'; if(!strcmp(buffer,temp)) flag=1; else flag=0; } return flag; } main() { int i,flag; init(); while(1) { flag=0; gets(word); if(!strcmp("XXXXXX",word)) break; for(i=0;i<nd;i++) if(unscramble(dic[i],word)) { puts(dic[i]); flag=1; } if(!flag) puts("NOT A VALID WORD"); puts("******"); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator