← Discussion

How do I right-justify numbers with more than 1 char to a column?

Chad · 2013-01-12 21:47:57

When you say "right-justified to a column x", do I need to align to column x the first character of the number or the last?

Say, my valid count and invalid count is both 10000. I need to justify them to columns 69 and 73, respectively. If I align to the first character ('1'), I get something like

Col:| 68 | 69 | 70 | 71 | 72 | 73 |
    |    |  1 |  0 |  0 |  0 |  0 |

And there's no way I can align invalid count on the first digit.

Similarly, if I align on the last digit, I either move the last '0' of valid count to 68 (in which case I fail the rule for valid count's alignment) or I keep it at col 69, start invalid count at col 70 and end it at col 74, failing the rule for valid count's alignment.

Demo Version · 2013-02-21 16:23:50

Hi Chad notice that

`There will be at most 1000 unique addresses in the input file. `

so it can not be 10000 to over load.

so what you should do is go on 69 column wich space before then print the valid then put (4-len(valid)) space then invalid count

wish that helped :)

pages:
  • 1