标签:int ++ ret 程序 include cout bsp span end
源程序:
//程序7-9
#include <iostream>
using namespace std;
int main()
{
double values[] = { 1.23,20.3456,300.4567,4000.56789,50000.1234567 };
cout.fill(‘*‘); //设置填充字符为星号 *
for (int i = 0; i<sizeof(values) / sizeof(double); i++)
{
cout << "values[" << i << "]=(";
cout.width(10); //设置输出宽度
cout << values[i] << ")" << endl;
}
cout.fill(‘ ‘);
for (int i = 0; i<sizeof(values) / sizeof(double); i++)
{
cout << "values[" << i << "]=(";
cout.width(10); //设置输出宽度
cout.precision(i + 3); //设置保留有效数字
cout << values[i] << ")" << endl;
}
system("pause");
return 0;
}
运行结果:
标签:int ++ ret 程序 include cout bsp span end
原文地址:https://www.cnblogs.com/duanqibo/p/12236008.html