Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(int argc, char const *argv[]) {
  5.     // Number 1
  6.     int rows, cols, val = 9;
  7.     rows = val;
  8.     while (rows >= 1) {
  9.         cols = 1;
  10.         while (cols <= rows) {
  11.             cout << rows;
  12.             cols++;
  13.         }
  14.  
  15.         cout << endl;
  16.         rows--;
  17.     }
  18.  
  19.     // Number 2
  20.     rows = 0; cols = 0;
  21.  
  22.     do {
  23.         cols = 1;
  24.         do {
  25.             cout << rows;
  26.             cols++;
  27.         } while (cols <= rows);
  28.  
  29.         rows++;
  30.         cout << endl;
  31.     } while (rows <= val);
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement