Guest User

hourglass

a guest
Dec 26th, 2014
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. void topTriangle(int num1, int k);
  4. void bottomTriangle(int num1, int k);
  5.  
  6. void main()
  7. {
  8.     int num1, k;
  9.     cout << "enter num1 and k" << endl;
  10.     cin >> num1 >> k;
  11.     topTriangle(num1, k);
  12.     bottomTriangle(num1, k);
  13.    
  14.    
  15. }
  16. void topTriangle(int num1,int k)
  17. {
  18.     int   line, j;
  19.     for (line = 1; line <= num1; line++)
  20.     {
  21.         for (j = 1; j < line; j++)
  22.         {
  23.             cout << " ";
  24.         }
  25.         for (j = line; j <= num1; j++)
  26.         {
  27.             cout << j;
  28.         }
  29.         for (j = num1 - 1; j >= line; j--)
  30.         {
  31.             cout << j;
  32.         }
  33.         cout << "\n";
  34.     }
  35. }
  36. void bottomTriangle(int num1,int k)
  37. {
  38.     int i, j, g;
  39.  
  40.     for (i = 1; i <= num1;i++)
  41.     {
  42.         for (j = 1; j <= (num1 - i - 1); j++)
  43.         {
  44.             cout << " ";
  45.         }
  46.         for (g = 1; g <= (2 * i + 1); g++)
  47.         {
  48.             cout << g;
  49.         }
  50.         cout << "\n";
  51.     }
  52.  
  53.  
  54.  
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment