2010-04-16 69 views

回答

13

<iomanip>包含流manipuator setw

cout << setw(2) << myint << endl 

您可能也有興趣setfill:

cout << setfill('0') << setw(2) << myint << endl 

意志墊以0代替空間。

4

你需要setw

+0

所以我會這樣做: setw(2)fo%2d? – aherlambang 2010-04-16 02:42:29

+0

是的。 COUT <<運輸及工務局局長(2)<<值<< ENDL; – codaddict 2010-04-16 02:43:30