BQ
Bùi Quốc Bảo
11 tháng 5 2022
```cpp
#include<iostream>
using namespace std;
float chu_vi(int a, int b){ //Tinh chu vi
float chu_vi = 2*(a+b);
return chu_vi;
}
float dien_tich(int a, int b){ //Tinh dien tich
float dien_tich = a*b;
return dien_tich;
}
int main(){
//Nhan a va b
float a, b;
cout<<"Nhap a (a>0): ";
cin>>a;
if (a<=0){ //Kiem tra a co lon hon 0
cout<<"a khong lon hon 0";
return 1;
}
cout<<"Nhap b (b>0): ";
cin>>b;
if (b<=0){ //Kiem tra b co lon hon 0
cout<<"b khong lon hon 0";
return 1;
}
cout << "Chu vi cua hinh la " << chu_vi(a, b) << endl;
cout << "Dien tich cua hinh la " << dien_tich(a, b);
}
```
Học tốt
Đúng(0)
BQ
Bùi Quốc Bảo
11 tháng 5 2022
Mình gửi lại
#include<iostream>
using namespace std;
float chu_vi(int a, int b){ //Tinh chu vi
float chu_vi = 2*(a+b);
return chu_vi;
}
float dien_tich(int a, int b){ //Tinh dien tich
float dien_tich = a*b;
return dien_tich;
}
int main(){
//Nhan a va b
float a, b;
cout<<"Nhap a (a>0): ";
cin>>a;
if (a<=0){ //Kiem tra a co lon hon 0
cout<<"a khong lon hon 0";
return 1;
}
cout<<"Nhap b (b>0): ";
cin>>b;
if (b<=0){ //Kiem tra b co lon hon 0
cout<<"b khong lon hon 0";
return 1;
}
cout << "Chu vi cua hinh la " << chu_vi(a, b) << endl;
cout << "Dien tich cua hinh la " << dien_tich(a, b);
}
Đúng(0)