标签:
Time Limit: 2000MS | Memory Limit: 65536K | |
Total Submissions: 20188 | Accepted: 7404 |
Description
Input
Output
Sample Input
i is has have be my more contest me too if award # me aware m contest hav oo or i fi mre #
Sample Output
me is correct aware: award m: i my me contest is correct hav: has have oo: too or: i is correct fi: i mre: more me
Source
1 #include<stdio.h> 2 #include<string.h> 3 char st[10010][20] ; 4 struct word_check 5 { 6 char src[20] ; 7 bool flag ; 8 int cnt , no[100] ; 9 }word[60]; 10 11 int k , f; 12 13 void check () 14 { 15 int diff ; 16 int ans ; 17 for (int i = 0 ; i < f ; i++) 18 for (int j = 0 ; j < k ; j++) 19 if (strcmp (word[i].src , st[j]) == 0) { 20 word[i].flag = 1 ; 21 } 22 23 for (int i = 0 ; i < f ; i++) 24 if (!word[i].flag) 25 for (int j = 0 ; j < k ; j++) { 26 diff = strlen (word[i].src) - strlen (st[j]) ; 27 if (diff == 0) { 28 ans = 0 ; 29 for (int l = 0 ; st[j][l] != ‘\0‘ ; l++) { 30 if (st[j][l] != word[i].src[l]) 31 ans ++ ; 32 if (ans > 1) 33 break ; 34 } 35 if (ans == 1) { 36 word[i].no [word[i].cnt] = j ; 37 word[i].cnt ++ ; 38 } 39 } 40 else if (diff == 1) { 41 int a = 0 ; 42 ans = 0 ; 43 for (int l = 0 ; word[i].src[l] != ‘\0‘ ; l++ , a++) { 44 if (st[j][a] != word[i].src[l]) { 45 ans ++ ; 46 a-- ; 47 } 48 if (ans > 1) 49 break ; 50 } 51 if (ans == 1) { 52 word[i].no[word[i].cnt] = j ; 53 word[i].cnt ++ ; 54 } 55 } 56 else if (diff == -1) { 57 int a = 0 ; 58 ans = 0 ; 59 for (int l = 0 ; st[j][a] != ‘\0‘ ; l++ , a++) { 60 if (st[j][a] != word[i].src[l]) { 61 ans ++ ; 62 l-- ; 63 } 64 if (ans > 1) 65 break ; 66 } 67 if (ans == 1) { 68 word[i].no[word[i].cnt] = j ; 69 word[i].cnt ++ ; 70 } 71 } 72 } 73 74 for (int i = 0 ; i < f ; i++) { 75 if (word[i].flag) { 76 printf ("%s is correct\n" , word[i].src) ; 77 } 78 else { 79 printf ("%s:" , word[i].src) ; 80 for (int j = 0 ; j < word[i].cnt ; j++) { 81 printf (" %s" , st[word[i].no[j]]) ; 82 83 } 84 //printf ("%d\n" , word[i].cnt) ; 85 printf ("\n") ; 86 } 87 } 88 } 89 90 91 int main () 92 { 93 // freopen ("a.txt" , "r" , stdin) ; 94 while (~ scanf ("%s" , st[0])) { 95 k = 0 ; 96 f = 0 ; 97 getchar () ; 98 while (1) { 99 gets (st[++k]) ; 100 if (strcmp (st[k] , "#") == 0) 101 break ; 102 } 103 while (1) { 104 gets (word[f].src) ; 105 word[f].cnt = 0 ; 106 f++ ; 107 if (strcmp (word[f - 1].src , "#") == 0) 108 break ; 109 } 110 f-- ; 111 /* for (int i = 0 ; i < k ; i++) 112 printf ("%d " , word[i].flag) ; 113 puts (""); 114 for (int i = 0 ; i < f ; i++) 115 puts (word[i].src) ;*/ 116 check () ; 117 } 118 return 0 ; 119 }
标签:
原文地址:http://www.cnblogs.com/get-an-AC-everyday/p/4320406.html