入出力も参照
#include <iostream> #include <iomanip> ... int main(){ unsigned num = 2; cout << setw(4) << setfill('0') << num << endl; → '0002' double fig = 0.15; fig+=1e-8; これがないと,切り上げの関係で '014' になる!!! cout << setw(3) << setfill('0') << (int)(100.0*fig) << endl; → '015' return 0; }