#include <iostream> #include <cstdint> #include <string> namespace { using uint_t = uint_fast32_t; using std::cin, std::cout; using std::string; constexpr uint_t PROG_1 = 10; constexpr uint_t PROG_2 = 20; constexpr uint_t MAX_FINAL = 2; } int main() { uint_t n; string s; uint_t x; uint_t ile = 0; cin >> n; for (uint_t k = 1; ile < PROG_2 && k <= n; ++k) { cin >> s >> x; if (s[0] == 'T') { if (ile < PROG_1) { cout << k << ' '; ++ile; } else if (x < MAX_FINAL && ile < PROG_2) { cout << k; ++ile; if (ile < PROG_2) cout << ' '; else cout << '\n'; } } } }
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 | #include <iostream> #include <cstdint> #include <string> namespace { using uint_t = uint_fast32_t; using std::cin, std::cout; using std::string; constexpr uint_t PROG_1 = 10; constexpr uint_t PROG_2 = 20; constexpr uint_t MAX_FINAL = 2; } int main() { uint_t n; string s; uint_t x; uint_t ile = 0; cin >> n; for (uint_t k = 1; ile < PROG_2 && k <= n; ++k) { cin >> s >> x; if (s[0] == 'T') { if (ile < PROG_1) { cout << k << ' '; ++ile; } else if (x < MAX_FINAL && ile < PROG_2) { cout << k; ++ile; if (ile < PROG_2) cout << ' '; else cout << '\n'; } } } } |