IO manipulators are your friends (include iomanip):
cout << "Case #" << i+1 << ": " << setfill('0') << setw(4) << res <<
endl;
On Sep 5, 8:24 am, MagicLi <[email protected]> wrote:
> Like in qualification round for Problem C, we have to show 0000
> instead of 0, I did it in a ugly way, change int to string type and
> then add '0' if num<1000, add '00' if num<100, add '000' if num<10;
> can anyone have a better way? BTW, do not use C-style output like
> fprintf(ofp, "Case #%d: %04d\n", t, d[i-1][18]); because I prefer
> ofstream instead of C-style FILE*.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-codejam" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-code?hl=en
-~----------~----~----~----~------~----~------~--~---