SHARE
TWEET

Bài 10 Tin

anhkiet2507 Apr 5th, 2019 6,733 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Bài 10. Tính diện tích các hình tùy người dùng chọn
  2. #include <iostream>
  3. using namespace std;
  4. double a, b, c, s;
  5.  
  6. int HinhTamGiac()
  7. {
  8.     cout << "Nhap canh doi dien: ";
  9.     cin >> a;
  10.     cout << "Nhap duong cao: ";
  11.     cin >> b;
  12.     s = (a*b) / 2;
  13.     cout << "Dien tich hinh tam giac la: " << s << endl;
  14.     return 0;
  15. }
  16.  
  17. int HinhBinhHanh()
  18. {
  19.     cout << "Nhap canh day: ";
  20.     cin >> a;
  21.     cout << "Nhap duong cao: ";
  22.     cin >> b;
  23.     s = a*b;
  24.     cout << "Dien tich hinh binh hanh la: " << s << endl;
  25.     return 0;
  26.  
  27. }
  28.  
  29. int HinhChuNhat()
  30. {
  31.     cout << "Nhap chieu rong: ";
  32.     cin >> a;
  33.     cout << "Nhap chieu dai: ";
  34.     cin >> b;
  35.     s = a*b;
  36.     cout << "Dien tich hinh chu nhat la: " << s << endl;
  37.     return 0;
  38. }
  39.  
  40. int HinhVuong()
  41. {
  42.     cout << "Nhap mot canh: ";
  43.     cin >> a;
  44.     s = a*a;
  45.     cout << "Dien tich hinh vuong la: " << s << endl;
  46.     return 0;
  47. }
  48.  
  49. int HinhTron()
  50. {
  51.     cout << "Nhap ban kinh: ";
  52.     cin >> a;
  53.     s = 3.14*a*a;
  54.     cout << "Dien tich hinh tron la: " << s << endl;
  55.     return 0;
  56. }
  57. int main()
  58. {
  59.     cout << "PHAN MEM TINH DIEN TICH CAC HINH" << endl;
  60.     cout << "Nhap cac con so duoi day de tinh dien tich cac hinh" << endl;
  61.     cout << "1. Hinh Tam Giac \n";
  62.     cout << "2. Hinh Binh Hanh \n";
  63.     cout << "3. Hinh Chu Nhat \n";
  64.     cout << "4. Hinh Vuong \n";
  65.     cout << "5. Hinh Tron \n";
  66.     cout << "Nhap su lua chon cua ban: ";
  67.     int x;
  68.     cin >> x;
  69.     if (x = 1)
  70.     {
  71.         HinhTamGiac();
  72.     }
  73.     if (x = 2)
  74.     {
  75.         HinhBinhHanh();
  76.     }
  77.     if (x = 3)
  78.     {
  79.         HinhChuNhat();
  80.     }
  81.     if (x = 4)
  82.     {
  83.         HinhVuong();
  84.     }
  85.     if (x = 5)
  86.     {
  87.         HinhTron();
  88.     }
  89.     system("pause");
  90.     return 0;
  91. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top