/* Entry for the Obfuscated V Contest, * http://graphics.stanford.edu/~danielrh/vote.html * Submitted by Kristian Nielsen */ #include #include int main(int argc, char *argv[]) { int kerry=0, bush=0, nader=0, total=0; int vote, next; /* Find first non-blank vote. */ while(isspace(next = getchar())); /* Loop over all the votes, stopping at end-of-file. */ while(next != EOF) { /* Get the current vote. */ vote = next; /* Find next non-blank vote. */ while(isspace(next = getchar())) /* Count the current vote. The 'other' votes are counted by subtracting from the vote total. */ if(vote == 'K') kerry++; if(vote == 'B') bush++; if(vote == 'N') nader++; total++; } /* Now output the tally. */ printf("Kerry: %d\n", kerry); printf("Bush: %d\n", bush); printf("Nader: %d\n", nader); printf("Other: %d\n", total - (kerry+bush+nader)); return 0; }