本帖最後由 劉漢文 於 2011-9-17 16:25 編輯
- #include <iostream>
- using namespace std;
- int main()
- {
- float x;
- float y;
- float z;
- cout<<"梯形面積計算程式"<<endl;
- cout<<"請輸入上底(cm)"<<endl;
- cin>>x;
- cout<<"請輸入下底(cm)"<<endl;
- cin>>y;
- cout<<"請輸入高(cm)"<<endl;
- cin>>z;
- cout<<"您輸入的上底是"<<x<<"您輸入的下底是"<<y<<"您輸入的高是"<<z<<endl;
- cout<<"答案是..."<<endl;
- cout<<"("<<x<<"+"<<y<<")"<<"*"<<z<<"/2="<<(x+y)*z/2<<平方公分endl;
- system("pause");
- return 0;
- }
複製代碼 |