本帖最後由 蔡沛倢 於 2022-12-2 20:15 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int y;
- cout<<"請輸入矩形的底"<<y<<endl;
- cin>>y;
- int x;
- cout<<"請輸入矩形的高"<<x<<endl;
- cin>>x;
- cout<<"矩形的高是"<<x<<"矩形的底是"<<y<<endl;
- cout<<"矩形的面積是:"<<y*x<<"周長是:"<<(y+x)*2<<endl;
- system("pause");
- return 0;
- }
複製代碼- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int y;
- cout<<"請輸入三角形的底"<<y<<endl;
- cin>>y;
- int x;
- cout<<"請輸入三角形的高"<<x<<endl;
- cin>>x;
- cout<<"三角形的高是"<<x<<"三角形的底是"<<y<<endl;
- cout<<"三角形的面積是: "<<y<<"*"<<x<<"/2"<<"="<<y*x/2<<endl;
- system("pause");
- return 0;
- }
複製代碼 |