Advertisement
Guest User

Problem1

a guest
Mar 6th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. int main()
  2. {
  3.     int number;
  4.  
  5.     cout << "Enter an odd number width: ";
  6.     cin >> number;
  7.     cout << number << endl << endl;
  8.  
  9.     cout << "Hill:" << endl;
  10.  
  11.     for (int a = 1; a <= number; a+=2)
  12.     {
  13.         for (int b = 1; b <= a; b++)
  14.         {
  15.             cout << "*";
  16.         }
  17.  
  18.         cout << endl;
  19.     }
  20.  
  21.     cout << "Triangle:" << endl;
  22.  
  23.     int tr = 1;
  24.  
  25.     for (int a = 1; a <= ((number / 2) + 1); a++)
  26.     {
  27.         for (int b = number; b >= a; b--)
  28.         {
  29.             cout << " ";
  30.         }
  31.  
  32.         for (int c = 0; c < tr; c++)
  33.         {
  34.             cout << "*";
  35.         }
  36.  
  37.         cout << endl;
  38.  
  39.         tr = tr + 2;
  40.     }
  41.  
  42.     cout << "Diamond:" << endl;
  43.    
  44.     int dia = 1;
  45.  
  46.     for (int a = 1; a <= ((number / 2) + 1); a++)
  47.     {
  48.         for (int b = number; b >= a; b--)
  49.         {
  50.             cout << " ";
  51.         }
  52.  
  53.         for (int c = 0; c < dia; c++)
  54.         {
  55.             cout << "*";
  56.         }
  57.  
  58.         cout << endl;
  59.  
  60.         dia = dia + 2;
  61.     }
  62.  
  63.     int dia2 = number;
  64.  
  65.     for (int a = 1; a <= ((number / 2) + 1); a++)
  66.     {
  67.         for (int b = number; b <= a; b--)
  68.         {
  69.             cout << " ";
  70.         }
  71.  
  72.         for (int c = 0; c < dia2; c++)
  73.         {
  74.             cout << "*";
  75.         }
  76.  
  77.         cout << endl;
  78.  
  79.         dia2 = dia2 - 2;
  80.     }
  81.  
  82.     return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement