#include<br>説明

3278 ワード

主にcin、coutなどの操作演算子、例えばsetfill、setw、setbase、setprecisionなどです.これはI/Oフロー制御ヘッダであり、Cのフォーマット出力のようなものである.一般的な制御関数は次のとおりです.
dec置基数10は「%d」に相当する
Hex置基数16は「%X」に相当
oct置基数8は「%o」に相当する
setfill(c)充填文字をcとする
setprecision(n)表示小数精度をnビットとする
setw(n)ドメイン幅をn文字とする
この制御子は、出力幅がnであることを保証することを意味する.次のようになります.
  cout<1 10100(デフォルトは右揃え)出力長が3より大きい場合(<1000)、setw(3)は機能しません.
setioflags(ios::fixed)固定浮動小数点表示
setioflags(ios::scientific)指数表現
setiosflags(ios::left)左揃え
setiosflags(ios::right)右揃え
setiosflags(ios::skipwsプリアンブル空白を無視
setiosflags(ios::uppercase)16進数大文字出力
setiosflags(ios::lowercase)16進小文字出力
setiosflags(ios::showpoint)強制小数点表示
setiosflags(ios::showpos)強制表示記号
例:
  #include
  #include
  using namespace std;
  int main()
  {
  cout<<12345.0<  cout<  cout<  cout<  return 0;
  }
以上
http://www.cppblog.com/masiyou/archive/2009/10/06/97948.aspx
#include <iostream>
#include <iomanip>

using namespace std;


int main()
{
	int x = 15;								      //Line 1			
	int y = 7634;							      //Line 2

	cout << "12345678901234567890" << endl;		  //Line 3
	cout << setw(5) << x << setw(7) << y
		 << setw(8) << "Warm" << endl;			  //Line 4

	cout << setfill('*');						  //Line 5
	cout << setw(5) << x << setw(7) << y
		 << setw(8) << "Warm" << endl;			  //Line 6			

	cout << setw(5) << x << setw(7) << setfill('#')	
		 << y << setw(8) << "Warm" << endl;		  //Line 7

	cout << setw(5) << setfill('@') << x
		 << setw(7) << setfill('#') << y
		 << setw(8) << setfill('^') << "Warm"
		 << endl;								  //Line 8

	cout << setfill(' ');						  //Line 9
	cout << setw(5) << x << setw(7) << y
		 << setw(8) << "Warm" << endl;			  //Line 10

	return 0;
}
    :
12345678901234567890
   15   7634    Warm
***15***7634****Warm
***15###7634####Warm
@@@15###7634^^^^Warm
   15   7634    Warm
Press any key to continue

めったに使わないiomanipの中の方法:
  cout << right;
  cout << setfill(' ');
  cout << setprecision(2);