Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream.h>
  2. #include <conio.h>
  3.  
  4. int main() {
  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.     getch();
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement