解题思路:
全部情况枚举
参考代码:
#include<bits/stdc++.h> using namespace std; int main() { int a[4]; memset(a, 0, sizeof(a)); for (int i = 0; i < 4; i++) { int count = 0; a[i] = 1; if ((a[1] == 0 && a[3] == 1)||(a[1] == 1 && a[3] == 0)) count++; if ((a[1] == 0 && a[2] == 1) || (a[1] == 1 && a[2] == 0)) count++; if ((a[0] == 0 && a[1] == 1) || (a[0] == 1 && a[1] == 0)) count++; if (a[3]==0|| a[3]==1) count++; if (count == 4) { if (i == 0) cout << "A"; else if(i == 1) cout << "B"; else if (i == 2) cout << "C"; else if (i == 3) cout << "D"; } memset(a, 0, sizeof(a)); } }
0.0分
3 人评分