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 |
新手,用c做的0.0#include <string.h> #include <stdio.h> char a[10000][20],b[10000][20]; int la,lb,l1,l2,book[10000]; void change(int x,int y) { int i=0,j=0,cnt=0; while(i<l1&&j<l2) { if (b[x][i]==a[y][j]) { i++; j++; } else { i++; j++; cnt++; } if (cnt>1) break; } if (cnt<=1) printf(" %s",a[y]); } void dele(int x,int y) { int i=0,j=0,cnt=0; while(i<l1&&j<l2+1) { if (b[x][i]==a[y][j]) { i++; j++; } else { i++; cnt++; } if (cnt>1) break; } if (cnt<=1) printf(" %s",a[y]); } void add(int x,int y) { int i=0,j=0,cnt=0; while(i<l1+1&&j<l2) { if (b[x][i]==a[y][j]) { i++; j++; } else { j++; cnt++; } if (cnt>1) break; } if (cnt<=1) printf(" %s",a[y]); } int main() { la=lb=0; int i,j; while(~scanf("%s",a[la])&&a[la][0]!='#') { la++; } a[la][0]='\0'; while(~scanf("%s",b[lb])&&b[lb][0]!='#') { lb++; } b[lb][0]='\0'; int flag; for (i=0; i<lb; i++) { flag=0; for (j=0; j<la; j++) { if (!strcmp(b[i],a[j])) { flag=1; break; } } if (!flag) book[i]=1; } int f; for (i=0; i<lb; i++) { f=0; if (!book[i]) { printf("%s is correct",b[i]); } else { printf("%s:",b[i]); for (j=0; j<la; j++) { l1=strlen(b[i]); l2=strlen(a[j]); if (l1==l2) { change(i,j); } else if (l1+1==l2) { add(i,j); } else if (l1==l2+1) { dele(i,j); } } } printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator