+ 1

cant allign using setw manipulator

The output is not properly alligned. The user enter the names and votes. Program outputs name votes recieved and percent of votes recieved by each candidate. I want to allign the outpot in a straight line but i cant. Sample input: Johnson 5000 Miller 4000 Duffy 6000 Robinson 2500 Ashtony 1800 Code: https://code.sololearn.com/c4A151a11a18

15th Dec 2020, 9:55 AM
Muhammad Abdullah
Muhammad Abdullah - avatar
3 Antworten
0
The biggest problem with aligning text is that each character differs in width. Perfect alignment is only possible where a monospace font is used to print outputs. To prove this, use 'AAA' as names for all of the candidates. The output will be well aligned when the 'name' field consists of characters having similar width.
15th Dec 2020, 10:34 AM
Ipang
0
Ipang that is problem the pro bn lem i want to solve. Keep same names and still align
15th Dec 2020, 11:01 AM
Muhammad Abdullah
Muhammad Abdullah - avatar
0
I know, I wish you luck buddy 👍
15th Dec 2020, 11:02 AM
Ipang