自考新教材-287

源程序:

//程序7-8

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

double x = 12.34;

cout << "1)" << setiosflags(ios::scientific | ios::showpos) << x << endl;

cout << "2)" << setiosflags(ios::fixed) << x << endl;

cout << "3)" << resetiosflags(ios::fixed) << setiosflags(ios::scientific | ios::showpos) << x << endl;

cout << "4)" << resetiosflags(ios::showpos) << x << endl;     //清除要输出正号的标志

system("pause");

return 0;

}

运行结果:

原文地址:https://www.cnblogs.com/duanqibo/p/12235997.html