Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <iostream>
  2. #include <thread>
  3. #include <chrono>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9.     float sequence;
  10.     float chain;
  11.  
  12.     cout << "Podaj wartość sekwencyjną: ";
  13.     cin >> sequence;
  14.     cout << "Podaj wartość łańcuchową: ";
  15.     cin >> chain;
  16.  
  17.     string out;
  18.  
  19.     for (int h = 0; h < chain; ++h) {
  20.         for (int i = 0; i < sequence; ++i) {
  21.             out = "";
  22.             for (int k = 0; k < sequence - i; ++k) {
  23.                 out += " ";
  24.             }
  25.             for (int j = -1; j < i * 2; ++j) {
  26.                 out += "*";
  27.             }
  28.  
  29.             this_thread::sleep_for(chrono::milliseconds(7));
  30.             cout << out << endl;
  31.         }
  32.         for (int i = sequence; i > -1; i--) {
  33.             out = "";
  34.             for (int k = 0; k < sequence - i; ++k) {
  35.                 out += " ";
  36.             }
  37.             for (int j = -1; j < i * 2; ++j) {
  38.                 out += "*";
  39.             }
  40.  
  41.             this_thread::sleep_for(chrono::milliseconds(7));
  42.             cout << out << endl;
  43.         }
  44.     }
  45.  
  46.     cout << endl;
  47.  
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement