Advertisement
annie_02

analog_2zad_dr

Oct 24th, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | Source Code | 0 0
  1. int main() {
  2.     int inNumber;
  3.     cin >> inNumber;
  4.     if (inNumber >= 1 && inNumber <= 9) {
  5.         for (int upperPart = 1; upperPart  <= inNumber; upperPart++) {
  6.             for (int spacing = 2; spacing <= upperPart; spacing++) {
  7.                 cout << " ";
  8.             }
  9.            
  10.             for (int countingUpper = upperPart; countingUpper <= inNumber; countingUpper++) {
  11.                 cout << countingUpper;
  12.             }
  13.             cout << endl;
  14.         }
  15.  
  16.         for (int bottomPart = 2; bottomPart <= inNumber; bottomPart++) {
  17.             for (int spacingBottom = 1; spacingBottom < inNumber; spacingBottom++) {
  18.                 cout << " ";
  19.             }
  20.  
  21.             int numberingDown = inNumber + 1;
  22.  
  23.             for (int countingDown = 1; countingDown <= bottomPart; countingDown++) {
  24.                 cout << --numberingDown;
  25.             }
  26.             if (bottomPart != inNumber) {
  27.                 cout << endl;
  28.             }
  29.         }
  30.     }
  31.     else {
  32.         cout << -1;
  33.     }
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement