Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Bài 10. Tính diện tích các hình tùy người dùng chọn
- #include <iostream>
- using namespace std;
- double a, b, c, s;
- int HinhTamGiac()
- {
- cout << "Nhap canh doi dien: ";
- cin >> a;
- cout << "Nhap duong cao: ";
- cin >> b;
- s = (a*b) / 2;
- cout << "Dien tich hinh tam giac la: " << s << endl;
- return 0;
- }
- int HinhBinhHanh()
- {
- cout << "Nhap canh day: ";
- cin >> a;
- cout << "Nhap duong cao: ";
- cin >> b;
- s = a*b;
- cout << "Dien tich hinh binh hanh la: " << s << endl;
- return 0;
- }
- int HinhChuNhat()
- {
- cout << "Nhap chieu rong: ";
- cin >> a;
- cout << "Nhap chieu dai: ";
- cin >> b;
- s = a*b;
- cout << "Dien tich hinh chu nhat la: " << s << endl;
- return 0;
- }
- int HinhVuong()
- {
- cout << "Nhap mot canh: ";
- cin >> a;
- s = a*a;
- cout << "Dien tich hinh vuong la: " << s << endl;
- return 0;
- }
- int HinhTron()
- {
- cout << "Nhap ban kinh: ";
- cin >> a;
- s = 3.14*a*a;
- cout << "Dien tich hinh tron la: " << s << endl;
- return 0;
- }
- int main()
- {
- cout << "PHAN MEM TINH DIEN TICH CAC HINH" << endl;
- cout << "Nhap cac con so duoi day de tinh dien tich cac hinh" << endl;
- cout << "1. Hinh Tam Giac \n";
- cout << "2. Hinh Binh Hanh \n";
- cout << "3. Hinh Chu Nhat \n";
- cout << "4. Hinh Vuong \n";
- cout << "5. Hinh Tron \n";
- cout << "Nhap su lua chon cua ban: ";
- int x;
- cin >> x;
- if (x = 1)
- {
- HinhTamGiac();
- }
- if (x = 2)
- {
- HinhBinhHanh();
- }
- if (x = 3)
- {
- HinhChuNhat();
- }
- if (x = 4)
- {
- HinhVuong();
- }
- if (x = 5)
- {
- HinhTron();
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement