#include <iostream> #include <string> using namespace std; int main() { int ideaCounter = 0; string litera = "ABC"; string liczba = "12345"; string dane = "#"; int wyniki[3][5]; cin >> ideaCounter; for (int i = 0; i < 3; i++) { for (int j = 0; j < 5; j++) { wyniki[i][j] = 0; } } int counter = 0; while (counter < ideaCounter) { cin >> dane; for (int i = 0; i < 5; i++) { for (int j = 0; j < 3; j++) { if (liczba[i] == dane[0]) { if (litera[j] == dane[1]) { wyniki[j][i] += 1; } } } } counter++; } /* for (int i = 0; i < 3; i++) { for (int j = 0; j < 5; j++) { cout << wyniki[i][j] << " "; } cout << endl; } */ int jedynki = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { if (wyniki[i][j] >= 1) jedynki++; } } int dwojki = 0; for (int j = 0; j < 3; j++) { if (wyniki[j][4] >= 2) dwojki++; } //cout << jedynki << endl; //cout << dwojki << endl; if (jedynki == 12 and dwojki == 3) cout << "TAK"; else cout << "NIE"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #include <iostream> #include <string> using namespace std; int main() { int ideaCounter = 0; string litera = "ABC"; string liczba = "12345"; string dane = "#"; int wyniki[3][5]; cin >> ideaCounter; for (int i = 0; i < 3; i++) { for (int j = 0; j < 5; j++) { wyniki[i][j] = 0; } } int counter = 0; while (counter < ideaCounter) { cin >> dane; for (int i = 0; i < 5; i++) { for (int j = 0; j < 3; j++) { if (liczba[i] == dane[0]) { if (litera[j] == dane[1]) { wyniki[j][i] += 1; } } } } counter++; } /* for (int i = 0; i < 3; i++) { for (int j = 0; j < 5; j++) { cout << wyniki[i][j] << " "; } cout << endl; } */ int jedynki = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { if (wyniki[i][j] >= 1) jedynki++; } } int dwojki = 0; for (int j = 0; j < 3; j++) { if (wyniki[j][4] >= 2) dwojki++; } //cout << jedynki << endl; //cout << dwojki << endl; if (jedynki == 12 and dwojki == 3) cout << "TAK"; else cout << "NIE"; } |