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

TOP

返回列表