|
|
вернуться в форумwhy WA#7??? Give me test!!! Послано tester 28 окт 2009 21:30 #include <stdio.h> #include <string.h> struct problem_1089 { char word[10]; int len; }; problem_1089 slovar[100] = {}; int n = 0; bool flag = false; char c; char str[1001] = {}; int len = 0; int count = 0; void check() { for (int i = 0; i < n; i++) { if (slovar[i].len == len) { int error = 0; for (int j = 0; j < len; j++) { if (str[j] != slovar[i].word[j]) error++; if (error > 1) break; } if (error == 1) { strcpy (str,slovar[i].word); count++; return; } } } return; } int main () { //freopen ("input.txt","r",stdin); //freopen ("output.txt","w",stdout); while (!flag) { gets(slovar[n++].word); slovar[n - 1].len = strlen (slovar[n - 1].word); if (strcmp(slovar[n - 1].word,"#") == 0) { flag = true; slovar[--n].word[0] = '\0'; slovar[n].len = 0; } } bool perevod = false; while (scanf ("%c", &c) != EOF) { flag = false; if (c > 96 && c < 123) str[len++] = c; else { check(); for (int i = 0; i < len; i++) printf ("%c", str[i]); if (c == '\n') perevod = true; else perevod = false; printf ("%c", c); len = 0; }
} if (len > 0) perevod = false; check(); for (int i = 0; i < len; i++) printf ("%c", str[i]); if (!perevod && !flag) printf ("\n%d", count); else printf ("%d", count); return 0; } Re: why WA#7??? Give me test!!! Hi, There can be more than 100 words in the vocabulary so don't read just first 100 words instead just read everything till you encounter # Varun |
|
|