20200807求梯形面积,要求输入浮点数,输出精度为2位

#include <bits/stdc++.h>
#include <iomanip> //precision要用
using namespace std;
double a,b,c,d;
int main()
{
  cin>>a>>b>>c;
  d=(a+b)*c/2;
  // printf("%.2lf",d);
  cout<<fixed<<setprecision(2)<<d<<endl; //fixed输出小数格式,如没有fixed,则输出整数,setprecision(2)精度为2
}

原文地址:https://www.cnblogs.com/whcsrj/p/13454988.html