//////////////////// /// Vote Counter /// /// Framework /// //////////////////// #include #include int main () { int Input; unsigned long total=0; unsigned long Tally[256]={0}; while ((Input=getchar())!=EOF) { unsigned char Vote=Input; if (!isspace(Vote)){ Tally[Input]+=1; total+=1; } } /**********************************************************************/ /* */ /* | | */ /* \ * * * * / Rice's theorem shows that whether or */ /* \ * * * / not programs correctly count votes is an A */ /* \ * * / undecidable problem. There must be obscure / \ */ /* \ * / ways to modify Tally['K'], Tally['N'] or / * \ */ /* \*/ Tally['B'] /* * *\ */ /* V \ * * / */ /* \ * / */ /* ...I couldn't think of any, so I submit for verification \ / */ /* the "sample program which properly counts the votes", V */ /* changed only to output (as required) a colon after the */ /* candidates' names. :) ;-| :*/ &=0 ;-// */ /* */ /**********************************************************************/ printf("Kerry: %d\n",Tally['K']); printf("Bush: %d\n",Tally['B']); printf("Nader: %d\n",Tally['N']); printf("Other: %d\n",total-Tally['K']-Tally['B']-Tally['N']); return 0; }