Advertisement
HaruKishima

source.cpp

Sep 25th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1. #include "header.h"
  2.  
  3. void TamGiacVuong1(int Cao)
  4. {
  5.     for (int i = 1; i <= Cao; i++)
  6.     {
  7.         for (int j = 1; j <= i; j++)
  8.         {
  9.             cout << "*";
  10.         }
  11.         cout << endl;
  12.     }
  13. }
  14.  
  15. void TamGiacVuong2(int Cao)
  16. {
  17.     for (int i = 1; i <= Cao; i++)
  18.     {
  19.         for (int k = 1; k <= Cao - i; k++)
  20.         {
  21.             cout << " ";
  22.         }
  23.         for (int j = 1; j <= i; j++)
  24.         {
  25.             cout << "*";
  26.         }
  27.         cout << endl;
  28.     }
  29. }
  30.  
  31. void TamGiacVuong3(int Cao)
  32. {
  33.     for (int i = 1; i <= Cao; i++)
  34.     {
  35.         for (int j = 0; j <= Cao - i; j++)
  36.         {
  37.             cout << "*";
  38.         }
  39.         cout << endl;
  40.     }
  41. }
  42.  
  43. void TamGiacVuong4(int Cao)
  44. {
  45.     for (int i = 1; i <= Cao; i++)
  46.     {
  47.         for (int k = 1; k <= i; k++)
  48.         {
  49.             cout << " ";
  50.         }
  51.         for (int j = 0; j <= Cao - i; j++)
  52.         {
  53.             cout << "*";
  54.         }
  55.         cout << endl;
  56.     }
  57. }
  58.  
  59.  
  60.  
  61. void printMenuTriangle()
  62. {
  63.     cout << "Chon loai tam giac ma ban muon ve: " << endl;
  64.     cout << "1." << endl;
  65.     TamGiacVuong1(3);
  66.     cout << "2." << endl;
  67.     TamGiacVuong2(3);
  68.     cout << "3." << endl;
  69.     TamGiacVuong3(3);
  70.     cout << "4." << endl;
  71.     TamGiacVuong4(3);
  72.     cout << "5." << endl;
  73.     TamGiacDeuDung(3);
  74.     cout << "6." << endl;
  75.     TamGiacDeuNguoc(3);
  76.     cout << "7. Thoat" << endl;
  77. }
  78.  
  79. void runMenuTriangle(int Cao)
  80. {
  81.     printMenuTriangle();
  82.     int lenh;
  83.     cin >> lenh;
  84.     system("cls");
  85.     switch (lenh)
  86.     {
  87.     case 1:
  88.         TamGiacVuong1(Cao);
  89.         system("pause");
  90.         break;
  91.     case 2:
  92.         TamGiacVuong2(Cao);
  93.         system("pause");
  94.         break;
  95.     case 3:
  96.         TamGiacVuong3(Cao);
  97.         system("pause");
  98.         break;
  99.     case 4:
  100.         TamGiacVuong4(Cao);
  101.         system("pause");
  102.         break;
  103.     case 5:
  104.         TamGiacDeuDung(Cao);
  105.         system("pause");
  106.         break;
  107.     case 6:
  108.         TamGiacDeuNguoc(Cao);
  109.         system("pause");
  110.         break;
  111.     case 7:
  112.         exit(0);
  113.     default:
  114.         cout << "Vui long nhap lai" << endl;
  115.         system("pause");
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement