|
|
вернуться в форумWhy I have WA3? Послано Denis 28 сен 2007 19:05 #include <fstream> #include <stdio.h> using namespace std; bool is_letter (char c) { return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); } bool is_b (char c) { return (c >= 'A' && c <= 'Z'); } bool is_s (char c) { return (c >= 'a' && c <= 'z'); } int main () { //freopen ("a.in", "r", stdin); //freopen ("a.out", "w", stdout); char c; bool f = true; bool g = true; int ans = 0; char s[10010]; int i; while (gets(s) != 0) { for (i = 0; i < strlen(s); ++i) { c = s[i]; //scanf ("%c", &c); if (c == '.' || c == '!' || c == '?') { f = true; g = true; } else { if (is_letter(c)) { if (is_b(c)) { if (!g) { ++ans; } } else if (is_s(c)) { if (f) { ++ans; } } f = false; g = false; } else { g = true; } } } } printf ("%d\n", ans); return 0; } Edited by author 28.09.2007 19:31 Re: Why I have WA3? Послано SHMAK 5 ноя 2007 05:36 i think that in test where are not only ( ,.:;!?)+('A'..'Z')+('a'..'z')+(0..9) symbols... Edited by author 05.11.2007 05:36 Re: Why I have WA3? Послано alp 12 янв 2008 01:51 3th test has digits in word. If word contains digit - it's word, but in text write "A word is a sequence of letters(!!!) not containing any other symbols or ends of line". The digits is ignored and the is checked the first letter after digits. Re: Why I have WA3? Try this test: A A answer = 0 Re: Why I have WA3? Hi, How come the answer is 0 ? This means, there is only one word in the entire text and that is AA. There is one mistake because second A is capital. Varun |
|
|