Please print the number of possible readings Farmer John could get from measuring the milk in the tank of the first barn after Friday.
My 1st INCORRECT Code
#include <iostream>
int main() {
int N; int cnt = 0;
int b[2][12];
int sub[2], add[2], tmp[200];
for (int i = 0; i < 2; i++)
for (int j = 0; j < 10; j++)
std::cin >> b[i][j];
for (int i = 0; i < 10; i++) {
if (sub[0] == b[0][i]) continue;
sub[0] = b[1][10] = b[0][i];
for (int j = 0; j < 11; j++) {
if (add[0] == b[1][j]) continue;
add[0] = b[0][10] = b[1][j];
for (int k = 0; k < 11; k++) {
if (sub[1] == b[0][k] || i == k) continue;
sub[1] = b[1][11] = b[0][k];
for (int h = 0; h < 12; h++) {
if (add[1] == b[1][h] || j == h) continue;
add[1] = b[1][h];
int idx = add[0] + add[1] - sub[0] - sub[1];
if (tmp[idx] != 1) {
tmp[idx] = 1; cnt++;
}
}
}
}
}
printf("%d", cnt);
}
comments
2020-01-16 …
