diff options
author | Vla Mai <[email protected]> | 2019-04-02 06:33:00 +0100 |
---|---|---|
committer | Vla Mai <[email protected]> | 2019-04-02 06:33:00 +0100 |
commit | c1a4b1788b3dc539c580394fe06b9699e8868a47 (patch) | |
tree | 6c0f371103acd03af947649f835bb5d4de696b8e | |
parent | 573e30c62deae1946f9d8c62c6e23a68d6208847 (diff) |
fix negative number print
-rw-r--r-- | src/main.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 3816377..43f23ef 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -110,14 +110,14 @@ fn pprint(ans: f64) { | |||
110 | fn thousand_sep(inp:&str) -> String{ | 110 | fn thousand_sep(inp:&str) -> String{ |
111 | let mut result_string = String::new(); | 111 | let mut result_string = String::new(); |
112 | for (i,c) in inp.to_string().chars().rev().enumerate(){ | 112 | for (i,c) in inp.to_string().chars().rev().enumerate(){ |
113 | if i % 3 == 0 && i != 0{ | 113 | if i % 3 == 0 && i != 0 && c.to_string() != "-"{ |
114 | result_string.push_str(","); | 114 | result_string.push_str(","); |
115 | result_string.push(c); | 115 | result_string.push(c); |
116 | continue | 116 | continue |
117 | } | 117 | } |
118 | result_string.push(c) | 118 | result_string.push(c) |
119 | } | 119 | } |
120 | let arrange:i16 = CONFIGURATION.fix as i16 - inp.len() as i16; | 120 | let arrange:i16 = CONFIGURATION.fix as i16 - result_string.len() as i16; |
121 | 121 | ||
122 | if arrange > 0 { | 122 | if arrange > 0 { |
123 | result_string.push_str(" ".repeat(arrange as usize).as_str()) | 123 | result_string.push_str(" ".repeat(arrange as usize).as_str()) |