Advertisement
X-88

ThousandSeparator.cpp

Jan 17th, 2022 (edited)
1,083
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. /*
  5. thousand separator,
  6. I'm just trying to translate it from delphi/pascal to c++, here's the original source link:
  7.  
  8. https://www.swissdelphicenter.ch/en/showcode.php?id=774
  9.  
  10. */
  11.  
  12. int i;
  13. string inp = "1234567890987654321", sep = ".";
  14.  
  15. int main()
  16. {
  17.     i = inp.length();
  18. while (i > 3)
  19. {
  20.     inp.insert(i - 3,  sep);
  21.     i -= 3;
  22. }
  23.     cout << inp;
  24.     return 0;
  25. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement