35657

Untitled

Nov 16th, 2023
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7.     setlocale(LC_ALL, "ru");
  8.  
  9.     // вывести квартиры от 1 до 40
  10.     for (int i = 0; i < 4; i++) {
  11.         for (int g = 0; g < 5; g++) {
  12.             for (int f = 1; f <= 2; f++) {
  13.                 cout << f + g * 2 + i * 10 << " ";
  14.             }
  15.         }
  16.     }
  17.     cout << endl;
  18.  
  19.     // определить этаж и подъезд квартиры по номеру
  20.  
  21.     int choice = 0;
  22.  
  23.     cout << "Введите номер квартиры: "; // от 1 до 40
  24.  
  25.     cin >> choice;
  26.  
  27.     for (int i = 0; i < 4; i++) {
  28.         for (int g = 0; g < 5; g++) {
  29.             for (int f = 1; f <= 2; f++) {
  30.                 if (f + g * 2 + i * 10 == choice)
  31.                 cout << "подъезд - " << i + 1 << ", этаж - " << g + 1 << endl;
  32.                 break;
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment