Advertisement
pan7nikt

zad_2_2

Oct 9th, 2023
974
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.27 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n = 0;
  9.     cout << "Podaj liczbe gwiazdek: ";
  10.     cin >> n;
  11.  
  12.     //Ile linii?
  13.     int lines = 0;
  14.     int chars = 0;
  15.     int lchars = 0;
  16.     while(chars<n)
  17.         {
  18.             lines++;
  19.             chars = chars+lines;
  20.         }
  21.     lchars = lines - (chars - n);
  22.  
  23.     cout << "\n Lines: " << lines;
  24.     cout << "\n Chars: " << chars;
  25.     cout << "\n Last line" << lchars;
  26.  
  27.     /*
  28.     for(int i=0; i<lines; i++)
  29.         {
  30.             while(chars<n && cline)
  31.             cout << "\naaaa";
  32.         }
  33.         */
  34.  
  35.  
  36.  
  37.     cout << "\n";
  38.     for(int i=0; i<lines-1; i++)
  39.         {
  40.             for(int j=0; j<=i; j++)
  41.                 {
  42.                     cout << "*";
  43.                 }
  44.             cout << "\n";
  45.         }
  46.         for(int j=0; j<lchars; j++)
  47.                 {
  48.                     cout << "*";
  49.                 }
  50.             cout << "\n";
  51.  
  52.     cout << "\n";
  53.  
  54.     for(int i=lines; i>0; i--)
  55.         {
  56.             for(int j=i; j>0; j--)
  57.                 {
  58.                     cout << "*";
  59.                 }
  60.             cout << "\n";
  61.         }
  62.  
  63.     cout << "\n";
  64.     for(int i=0; i<lines; i++)
  65.         {
  66.  
  67.             for(int k=0; k<i; k++)
  68.                 {
  69.                     cout << " ";
  70.                 }
  71.             for(int j=(lines-i); j>0; j--)
  72.                 {
  73.                     cout << "*";
  74.                 }
  75.             cout << "\n";
  76.         }
  77.  
  78.     cout << "\n";
  79.     for(int i=0; i<n; i++)
  80.         {
  81.  
  82.             for(int k=(n-i); k>1; k--)
  83.                 {
  84.                     cout << " ";
  85.                 }
  86.             for(int j=0; j<=i; j++)
  87.                 {
  88.                     cout << "*";
  89.                 }
  90.             cout << "\n";
  91.         }
  92.  
  93.     cout << "\n";
  94.     for(int i=0; i<n; i++)
  95.         {
  96.             for(int j=0; j<((n-i)/2); j+=2)
  97.                 {
  98.                     cout << " ";
  99.                 }
  100.             for(int j=0; j<i; j+=2)
  101.                 {
  102.                     cout << "*";
  103.                 }
  104.                 /*
  105.             for(int j=0; j<(n-i)/2; j++)
  106.                 {
  107.                     cout << " ";
  108.                 }
  109.                 */
  110.                 cout << "|\n";
  111.         }
  112.  
  113.  
  114.  
  115. }
  116.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement