- #include<iostream>
- #include<cstdlib>
- using namespace std;
- float tri(float,float);
- float cir(float);
- float rec(float,float);
- float tra(float,float,float);
- int main()
- {
- int fuckyou;
- float x,y,z;
- cout<<"請問您要計算哪一種形狀的面積? <1>三角形 <2>圓形 <3>長方形 <4> 梯形"<<endl;
- cin>>fuckyou;
- if(fuckyou==1)
- tri(x,y);
- else if(fuckyou==2)
- cir(x);
- else if(fuckyou==3)
- rec(x,y);
- else if(fuckyou==4)
- tra(x,y,z);
- else
- {
- cout<<"輸入錯誤!"<<endl;
- }
- system("pause");
- return 0;
- }
- float tri(float a,float b)
- {
- cout<<"請輸入三角形的底(公分): ";
- cin>>a;
- cout<<"請輸入三角形的高(公分): ";
- cin>>b;
- cout<<"此三角形面積為: "<<a*b/2<<"平方公分"<<endl;
- }
- float cir(float a)
- {
- cout<<"請輸入圓形的半徑(公分): ";
- cin>>a;
- cout<<"此圓形面積為約: "<<a*a*3.14<<"平方公分"<<endl;
- }
- float rec(float a,float b)
- {
- cout<<"請輸入三角形的長: ";
- cin>>a;
- cout<<"請輸入三角形的寬: ";
- cin>>b;
- cout<<"此長方形面積為: "<<a*b<<"平方公分"<<endl;
- }
- float tra(float a,float b,float c)
- {
- cout<<"請輸入梯形的上底: ";
- cin>>a;
- cout<<"請輸入梯形的下底: ";
- cin>>b;
- cout<<"請輸入梯形的高: ";
- cin>>c;
- cout<<"此梯形面積為: "<<(a+b)*c/2<<"平方公分"<<endl;
- //大文豪兼大帥哥的作品 哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
- }
複製代碼 |