Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int floorCount, floorFlatCount;
- cin >> floorCount >> floorFlatCount;
- string appendix;
- for (int f = floorCount; f > 0; f--) {
- if (f == floorCount) {
- appendix = "L";
- }
- else if (f % 2 == 1) {
- appendix = "A";
- }
- else {
- appendix = "O";
- }
- for (int n = 0; n < floorFlatCount; n++) {
- cout << appendix << f << n << " ";
- }
- cout << endl;
- }
- return 0;
- }
- Решение с тернарен оператор:
- #include <iostream>
- using namespace std;
- int main() {
- int floorCount, floorFlatCount;
- cin >> floorCount >> floorFlatCount;
- string appendix;
- for (int f = floorCount; f > 0; f--) {
- appendix =
- f == floorCount ? "L" :
- f % 2 == 1 ? "A" : "O";
- for (int n = 0; n < floorFlatCount; n++) {
- cout << appendix << f << n << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement