2017年9月16日 星期六

[C_MM01-易] 計算梯型面積(C++)



  1. #include<iostream>  
  2. #include<iomanip>  
  3.   
  4. using namespace std;  
  5.   
  6. int main() {  
  7.     int top_base, under_base, high;  
  8.     cin >> top_base >> under_base >> high;  
  9.     float area;  
  10.     area = (top_base+under_base)*high/2.0;  
  11.     cout << "Trapezoid area:" << fixed << setprecision(1) << (float)area << endl;  
  12.     return 0;  
  13. }  

沒有留言:

張貼留言