#include<iostream>
#include<iomanip>
using namespace std;
int main(void){
double s;
cin>>s;
if(s*95>=300){
cout<<setiosflags(ios::fixed)<<setprecision(2)<<s*95*0.85<<endl;
}
else{
cout<<setiosflags(ios::fixed)<<setprecision(2)<<s*95<<endl;
}
return 0;
}
Floating point output can be changed with << setiosflags( ios::fixed ) : never use scientific notation //绝对不使用科学记数法。 << setiosflags( ios::scientific ) : always use scientific notation //使用科学记数法。 << resetiosflags( ios::floatfield ) : restores default (use fixed or scientific notation based on the precision)//重置为缺省。 << (re)setiosflags( ios::showpoint ) : controls if the trailing zeros and decimal point will be output (default is no) //控制小数点后面的零是否显示。 << setprecision( digits ) : if fixed or scientific format is selected, controls the number of digits after the decimal place, otherwise controls the total number of significant digits// 如果fixed或者scientific已经确定了,则控制小数点后面的位数;否则,控制所有位数。
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
double S = 0.000000123;
double A = 456.7;
double B = 8910000000000.0;
cout << "default precision is "
<< cout.precision() << endl; // 6
cout << " S = " << S << endl; // 1.23e-07
cout << " A = " << A << endl; // 456.7
cout << " B = " << B << endl; // 8.91e+12
cout << setiosflags(ios::showpoint)
<< "ios::showpoint ON" << endl;
cout << " S = " << S << endl; // 1.23000e-07
cout << " A = " << A << endl; // 456.700
cout << " B = " << B << endl; // 8.91000e+12
cout << resetiosflags(ios::showpoint)
<< "ios::showpoint OFF" << endl;
cout << setiosflags(ios::fixed)
<< "ios::fixed ON" << endl;
cout << " S = " << S << endl; // 0.000000
cout << " A = " << A << endl; // 456.700000
cout << " B = " << B << endl; // 8910000000000.000000
cout << resetiosflags(ios::fixed)
<< setiosflags(ios::scientific)
<< "ios::scientific ON" << endl;
cout << " S = " << S << endl; // 1.230000e-07
cout << " A = " << A << endl; // 4.567000e+02
cout << " B = " << B << endl; // 8.910000e+12
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有