Judge the coin problem. This problem does not know how to do, see the other people's discuss have a train of thought.
One, even, both sides are real coins
Two, non-even when, not on the balance are real coins
Third, once thought may be biased, and appear on the side of the light is the real currency.
We can use an array zeros storage must be real, that is, those that appear in the even case; another array of SUS stores suspicion of possible counterfeit money, when it appears on the up, the left side of the coin sus--, the right side of the + +. Down in turn, so that we can judge the positive or negative to determine whether the counterfeit currency is light or heavy, and is considered to be biased, but also appear on the lighter side of SUS naturally will first + +, after-restore to 0.
#include <stdio.h> #include <string.h> #define ABS (x) (x>=0 x:-X) #define MAX (x, y) (x>y?x:y) int sus[13 ];int Zeros[13];int Main () {int t,i,j;scanf ("%d", &t), while (t--) {char left[3][6],right[3][6],status[3][6]; memset (sus,0,sizeof (SUS)); memset (zeros,0,sizeof (zeros)); for (i=0;i<3;i++) {scanf ("%s%s%s", Left[i],right[i], Status[i]);} for (i=0;i<3;i++) {if (strcmp (Status[i], "even") ==0) {for (J=0;j<strlen (Left[i]); j + +) {zeros[left[i][j]-65] = 1; ZEROS[RIGHT[I][J]-65] = 1; }}}for (i=0;i<3;i++) {if (strcmp (Status[i], "up") ==0) {for (J=0;j<strlen (Left[i]); j + +) {sus[left[i][j]-65]--; sus[right[i][j]-65]++;}} else if (strcmp (Status[i], "down") ==0) {for (J=0;j<strlen (Left[i]); j + +) {sus[right[i][j]-65]--;sus[left[i][j]-65] ++;}}} int m =0,maxval = 0;for (i=0;i<13;i++) {if (ABS (Sus[i]) >=maxval && zeros[i]!=1) {maxval = ABS (Sus[i]); m=i;}} if (sus[m]>0) printf ("%c is the counterfeit coin and it was light.\n", m+65), Else printf ("%c is the counterfeit coin and I T is heavy.\n ", m+65);} REturn 0;}
POJ Miscellaneous Questions-1013 Counterfeit Dollar