10_各行小数点对齐.cpp

//2012-9-29 17:07:56

#include <iostream>

#include <iomanip>

using namespace std;

int main()
{
	double a = 123.456, b = 3.14159, c = -3214.67;
	cout<<setiosflags(ios::fixed)<<setprecision(2)<<setiosflags(ios::right);
	cout<<setw(10)<<a<<endl;
	cout<<setw(10)<<b<<endl;
	cout<<setw(10)<<c<<endl;

	return 0;
}

/*
在VC++6.0中运行的结果是:
-----------------------
    123.46
      3.14
  -3214.67
Press any key to continue
-----------------------
*/

你可能感兴趣的:(ios,c,vc++)