diff options
Diffstat (limited to 'other/thousand_separator.cpp')
-rw-r--r-- | other/thousand_separator.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/other/thousand_separator.cpp b/other/thousand_separator.cpp new file mode 100644 index 0000000..a0493f5 --- /dev/null +++ b/other/thousand_separator.cpp @@ -0,0 +1,20 @@ +#include "leetcode.h" +#include <cmath> +#include <string> + +class Solution { +public: + string thousandSeparator(int n) { + string s = to_string(n); + if (trunc(log10(n)) + 1 < 4) + return s; + + return s; + } +}; + +int main() { + Solution obj; + obj.thousandSeparator(1234); + // cout << obj.thousandSeparator(1234); +} |