怎么才能使得前边有个0
比如:cout<<oct<<146<<endl;
输出的是222. 怎么修改才能使其输出为: 0222
ãã// 使ç¨cout/pintfè¾åº16è¿å¶ï¼8è¿å¶ï¼2è¿å¶æ°æ®
ãã#include <iostream>
ãã#include <bitset>
ãã#include <stdlib.h>
ããusing namespace std;
ããint main()
ãã{
ããprintf(" 使ç¨cout/pintfè¾åº16è¿å¶ï¼8è¿å¶ï¼2è¿å¶æ°æ®\n");
ããprintf(" - http://blog.csdn.net/morewindows/article/details/16358511 -\n");
ããprintf(" -- By MoreWindows( http://blog.csdn.net/MoreWindows ) --\n\n");
ãã
ããint a = 100;
ããcout<<"åè¿å¶ "<<a<<endl;
ããcout<<"åå è¿å¶ "<<hex<<a<<endl;
ããcout<<"å «è¿å¶ "<<oct<<a<<endl;
ããcout<<"äºè¿å¶ "<<bitset<8>(a)<<" "<<bitset<32>(a)<<endl; // è¿é使ç¨äºbitsetç±»æ¥è¾åº2è¿å¶æ°æ®
ãã
ããcout<<"--------------------------------"<<endl;
ãã
ããprintf("åè¿å¶ %d\n", a);
ããprintf("åå è¿å¶ %x\n", a);
ããprintf("å «è¿å¶ %o\n", a);
ããchar binary_text[100];
ããitoa(a, binary_text, 2);
ããprintf("äºè¿å¶ %s\n", binary_text);
ããreturn 0;
ãã}