1234567891011121314151617181920212223
#include <iostream> #include <iomanip> using namespace std; int main() { short int a[4] = {0,2,3,4}; short int b = 0; for (int i=0; i<4; ++i) { b *= 10; b += a[i]; } // default display cout << "b = " << b << '\n'; //display with leading zeros cout << setfill('0'); cout << "b = " << setw(4) << b << '\n'; }
b = 234 b = 0234
short int b=0234
12345678
#include <iostream> using namespace std; int main() { int b = 0234; cout << b << "\n"; return 0; }