Advertisement
AndriikoM

Лекція 3, завдання 3

Oct 30th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a[20];
  8.     int max=a[0];
  9.     int imax=-1;
  10.     cout << "Enter elementi massiva: " << endl;
  11.     for ( int i = 0; i < 20; i++ )
  12.     {
  13.         cin >> a[i];
  14.         if (a[i]==0)
  15.         {
  16.             i=19;
  17.         }
  18.         imax++;
  19.     }
  20.     for (int i=0; i<imax; i++)
  21.     {
  22.         if (a[i] > max)
  23.         {
  24.             max = a[i];
  25.         }
  26.     }
  27.     for (int i=0; i<imax; i++)
  28.     {
  29.         int c;
  30.         int d;
  31.         c=(max-a[i])/2+0.5;
  32.             while (c>0)
  33.             {
  34.                 cout << " ";
  35.                 c--;
  36.             }
  37.             d=0;
  38.             while (d<(a[i]))
  39.             {
  40.                 cout << "*";
  41.                 d++;
  42.             }
  43.         cout<< endl;
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement