warfighter67

help

Oct 17th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. string strOut = "";
  2.  
  3.     strOut = to_string(static_cast<long long>(num));
  4.  
  5.     for(int i = 0; i < strOut.size() - 1; i++)
  6.     {
  7.         if((strOut.size() - (i+1)) % 3 == 0)
  8.         {
  9.             i++;
  10.             strOut.insert(i, ",");
  11.         }
  12.     }
  13.  
  14.     if(*strOut.begin() == ',')
  15.     {
  16.         strOut.erase(0, 1);
  17.     }
  18.  
  19.     strOut.insert(strOut.begin(), '$');
  20.  
  21.     return strOut;
Advertisement
Add Comment
Please, Sign In to add comment