返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. float tri(float,float);
  5. int main()
  6. {
  7.     float x,y;
  8.     cout<<"請輸入三角形的底(公分):";
  9.     cin>>x;
  10.     cout<<"請輸入三角形的高(公分):";
  11.     cin>>y;
  12.     cout<<"此三角形的面積為"<<tri(x,y)<<"平方公分"<<endl;
  13.    
  14.     system("pause");
  15.     return 0;   
  16. }
  17. float tri(float a,float b)
  18. {
  19.     return a*b/2;  
  20. }
複製代碼

TOP

返回列表