util.cpp 319 B

12345678910111213141516171819202122
  1. #include <cstdlib>
  2. #include "util.h"
  3. void append_expn(std::string &str, int expn) {
  4. int k;
  5. str += (expn < 0 ? '-' : '+');
  6. expn = std::abs(expn);
  7. if (expn >= 100) {
  8. k = (expn / 100);
  9. str += '0' + k;
  10. expn -= 100*k;
  11. }
  12. k = (expn / 10);
  13. str += '0' + k;
  14. expn -= 10*k;
  15. str += '0' + expn;
  16. }