Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<string.h>
- #include<math.h>
- using namespace std;
- class Triangle{
- public:
- int a,b,c;
- string color;
- Triangle(){
- cout << "Конструктор" << endl;
- }
- Triangle(int _a, int _b, int _c, string _color){
- a=_a;
- b=_b;
- c=_c;
- color=_color;
- }
- void setSide(){
- cout<<"Введіть сторону а: ";
- cin>>a;
- cout<<"Введіть сторону б: ";
- cin>>b;
- cout<<"Введіть сторону с: ";
- cin>>c;
- cout<<"Введіть колір: ";
- cin>>color;
- }
- double getPer(){
- return a+b+c;
- }
- double getSquare(){
- double p=getPer()/2;
- return sqrt(p*(p-a)*(p-b)*(p-c));
- }
- void print(){
- cout<<"Сторона а: "<<a<<endl;
- cout<<"Сторона б "<<b<<endl;
- cout<<"Сторона с: "<<c<<endl;
- cout<<"Колір: "<<color<<endl;
- cout<<"Периметр: "<<getPer()<<endl;
- cout<<"Плоша: "<<getSquare()<<endl;
- }
- };
- int main()
- {
- Triangle obj;
- obj.setSide();
- obj.print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement