// SIO2 Potyczki Algorytmiczne 2020, runda pierwsza [C].cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> #include <string> using namespace std; int main(int argc, char* argv[]) { char digit_set[] = { '1', '2', '3', '4', '5' }; char letter_set[] = { 'A', 'B', 'C' }; string letter_digit_set; size_t found; for (const char& it1 : digit_set) { for (const char& it2 : letter_set) { if (it1 == '5') { letter_digit_set += std::string() + it1 + it2; letter_digit_set += std::string() + it1 + it2; } else { letter_digit_set += std::string() + it1 + it2; } } } for (int i = 2; i <= int(argv[1])+2; i++) { found = letter_digit_set.find(argv[i]); if (found != string::npos) { letter_digit_set = letter_digit_set.erase(found, 2); } if (letter_digit_set.size() < 2){ break; } } if (letter_digit_set.size() < 2) { cout << "TAK"; } else { cout << "NIE"; } return(0); }
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 | // SIO2 Potyczki Algorytmiczne 2020, runda pierwsza [C].cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> #include <string> using namespace std; int main(int argc, char* argv[]) { char digit_set[] = { '1', '2', '3', '4', '5' }; char letter_set[] = { 'A', 'B', 'C' }; string letter_digit_set; size_t found; for (const char& it1 : digit_set) { for (const char& it2 : letter_set) { if (it1 == '5') { letter_digit_set += std::string() + it1 + it2; letter_digit_set += std::string() + it1 + it2; } else { letter_digit_set += std::string() + it1 + it2; } } } for (int i = 2; i <= int(argv[1])+2; i++) { found = letter_digit_set.find(argv[i]); if (found != string::npos) { letter_digit_set = letter_digit_set.erase(found, 2); } if (letter_digit_set.size() < 2){ break; } } if (letter_digit_set.size() < 2) { cout << "TAK"; } else { cout << "NIE"; } return(0); } |