Advertisement
Guest User

Untitled

a guest
Oct 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void troj_A() {
  6.     int x, y, h;
  7.     cout << "Podaj h: \n"; cin >> h;
  8.     cout << "Podaj x: \n"; cin >> x;
  9.     cout << "Podaj y: \n"; cin >> y;
  10.  
  11.     for(int i = 0; i < y - 1; i++) {
  12.         cout << "\n";
  13.     }
  14.  
  15.     for(int i = 1; i <= h; i++) {
  16.         for (int j = 0; j < x - 1; j++) {
  17.             cout << " ";
  18.         }
  19.     for(int j = 0; j < 2 * h - ((2 * i) - 1); j++) {
  20.         cout << "*";
  21.     }
  22.  
  23.     cout << "\n";
  24.     }
  25. }
  26.  
  27. void troj_B() {
  28.     int x, y, h;
  29.     cout << "Podaj h: \n"; cin >> h;
  30.     cout << "Podaj x: \n"; cin >> x;
  31.     cout << "Podaj y: \n"; cin >> y;
  32.     int i = 1;
  33.     while (i < y - ( h / 2 ) - 1) {
  34.         cout << "\n";
  35.         i++;
  36.         }
  37.  
  38.     i = 0;
  39.         while (i <= (h - 1) / 2) {
  40.     int j = 0;
  41.         while (j < x - (( h + 1 ) / 2)) {
  42.             cout << " ";
  43.             j++;
  44.         }
  45.     j = 0;
  46.         while (j < i) {
  47.             cout << "*";
  48.             j++;
  49.     }
  50.     cout << "\n";
  51.     i++;
  52.     }
  53.  
  54.     i = 0;
  55.     while (i < x - (h + 1) / 2) {
  56.             cout << " ";
  57.             i++;
  58.     }
  59.  
  60.     i = 0;
  61.     while (i < ( h + 1 ) / 2) {
  62.             cout << "*";
  63.             i++;
  64.     }
  65.     cout << "\n";
  66.  
  67.     i = 0;
  68.     while (i <= (h - 1) / 2) {
  69.     int j = 0;
  70.     while (j < x - (( h + 1) / 2)) {
  71.             cout << " ";
  72.             j++;
  73.         }
  74.     j = ( ( h - 1 ) / 2 ) - 1 ;
  75.     while (j >= i) {
  76.             cout << "*";
  77.             j--;
  78.     }
  79.     cout << "\n";
  80.     i++;
  81.     }
  82. }
  83.  
  84. void troj_C() {
  85.  
  86. }
  87.  
  88. int main() {
  89.     char w;
  90.     do {
  91.         cout << "Rysuj trojkat A - A";
  92.         cout << "\nRysuj trojkat B - B";
  93.         cout << "\nRysuj trojkat C - C";
  94.         cout << "\nKoniec - K\n";
  95.         cin >> w;
  96.         switch (w) {
  97.             case 'A' : troj_A(); break;
  98.             case 'B' : troj_B(); break;
  99.             case 'C' : troj_C(); break;
  100.         }
  101.         cout << "\n";
  102.     } while (w!='K'&&w!='k');
  103. system("PAUSE");
  104. return 0;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement