/*24种情况,挨个试*/ #include<stdio.h> #include<string.h> static int flag = 0; typedef struct { char S1[20]; char S2[20]; char S3[20]; } clue; int f(int i, int j, char* S, char* T) { int k, len = strlen(S); char c = 'A' + i; if (j == 0) { for (k = 0; k < len && S[k] != c; k++); if (k < len / 2 && strcmp(T, "down") == 0)flag++; else if (k >= len / 2 && k < len && strcmp(T, "up") == 0)flag++; else if (k == len && strcmp(T, "even") == 0)flag++; } else if (j == 1) { for (k = 0; k < len && S[k] != c; k++); if (k < len / 2 && strcmp(T, "up") == 0)flag++; else if (k >= len / 2 && k < len && strcmp(T, "down") == 0)flag++; else if (k == len && strcmp(T, "even") == 0)flag++; } return 0; } int main() { clue A[3]; int i, j, k, fakenum, state, weight; scanf("%d", &weight); for (i = 0; i < 3; i++) { for (j = 0; j < 20; j++) { A[i].S1[j] = A[i].S2[j] = A[i].S3[j] = '\0'; } } for (i = 0; i < 3; i++) { scanf("%s %s %s", A[i].S1, A[i].S2, A[i].S3); strcat(A[i].S1, A[i].S2); } for (j = 0; j < 2; j++) for (i = 0; i < 12; i++) { flag = 0; for (k = 0; k < 3; k++) f(i, j, A[k].S1, A[k].S3); if (flag == 3) { fakenum = i; state = j; goto out; }; } out: ; char result[10]; for (i = 0; i < 10; i++)result[i] = '\0'; if (state == 0)strcat(result, "light"); else strcat(result, "heavy"); printf("%c is the counterfeit coin and it is %s.\n", fakenum + 'A', result); return 0; }