dimanche 19 juillet 2015

Output alignment issue

I am not sure how to make it align the decimal points up. Any ideas?

/* print the tempature at each hour 1 to 24 */
    for (int k = 0; k < day1Temps.size(); ++k) {
        cout << left << setw(20) << k << "           " << day1Temps[k] << setw(15) << " " << day2Temps[k] << endl;
    }

outputs:

Hour                           6/14/2015         6/15/2015
0                              0               0
1                              3.11               26.11
2                              4.11               27.11
3                              5.11               28.11
4                              6.11               29.11
5                              7.11               30.11
6                              8.11               30.11
7                              9.11               32.11
8                              10.11               33.11
9                              11.11               34.11
10                             12.11               35.11
11                             13.11               36.11
12                             14.11               37.11
13                             15.11               38.11 
14                             16.11               39.11
15                             17.11               40.11
16                             18.11               41.11
17                             19.11               42.11
18                             20.11               43.11
19                             21.11               44.11
20                             22.11               45.11
21                             23.11               46.11
22                             24.11               47.11
23                             25.11               48.11

adding some more text because it says to.

Aucun commentaire:

Enregistrer un commentaire