cpp笔记1:保留小数点后n位

chamodsd edited 5 年,6 月前

保留小数点后n位:
cout << fixed << setprecision(2)<< (float)a[res]/sum;
或者:
cout.setf(ios::fixed);
cout<< setprecision(2) << (float)a[res]/sum;

Comments