UVa 494 Kindergarten Counting Game
一次AC!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* UVa 494 | |
* Author: chchwy | |
* Last Modified: 2009.10.30 | |
*/ | |
#include <iostream> | |
#include <cctype> | |
int main() | |
{ | |
#ifndef ONLINE_JUDGE | |
freopen("494.in", "r", stdin); | |
#endif | |
int counter = 0; | |
char cur = 0, prev = 0; | |
while ( (cur = getchar()) != EOF ) | |
{ | |
if (cur == '\n') | |
{ | |
printf("%d\n", counter); | |
counter = 0; | |
prev = 0; | |
} | |
if ( isalpha(cur) && !isalpha(prev) ) | |
counter++; | |
prev = cur; | |
} | |
return 0; | |
} |
留言
張貼留言