Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. using namespace std;
  4.  
  5. enum Color { Black = 0, Blue, Green, Cyan, Red, Magenta, Brown, LightGray, DarkGray, LightBlue = 9, LightGreen, LightCyan, LightRed, LightMagenta, Yellow, White };
  6. HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
  7. void SetColor(Color text, Color background)
  8. {
  9.     SetConsoleTextAttribute(hStdOut, (WORD)((background << 4) | text));
  10. }
  11.  
  12. void main()
  13. {
  14.     setlocale(0, "Russian");
  15.  
  16.     char loop;
  17.     do
  18.     {
  19.         system("cls");
  20.  
  21.         int menu;
  22.  
  23.  
  24.         cout << "Введите номер треугольника (1-4)" << endl;
  25.         cin >> menu;
  26.  
  27.         int base;
  28.         cout << "Введите ширину основания треугольника" << endl;
  29.         cin >> base;
  30.  
  31.         if (base % 2 == 0)
  32.         {
  33.             base++;
  34.         }
  35.  
  36.         if (menu == 1)
  37.         {
  38.             for (size_t i = 0; i < base/2+1; i++)
  39.             {
  40.                 for (size_t j = 0; j < base; j++)
  41.                 {
  42.                     if (j == base / 2 || (j >= base / 2 - i && j <= base / 2 + i))
  43.                     {
  44.                         cout << "*";
  45.                     }
  46.                     else
  47.                     {
  48.                         cout << " ";
  49.                     }
  50.                 }
  51.                 cout << endl;
  52.             }
  53.         }
  54.         else if (menu == 2)
  55.         {
  56.  
  57.         }
  58.         else if (menu == 3)
  59.         {
  60.  
  61.         }
  62.         else if (menu == 4)
  63.         {
  64.  
  65.         }
  66.         else
  67.         {
  68.             cout << "У меня для вас плохие новости, вы аутист..." << endl;
  69.         }
  70.  
  71.         cout << "Продолжить ? (y - Да, n - Нет)" << endl;
  72.         cin >> loop;
  73.     }
  74.     while (loop=='y'||loop=='Y');
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement