简体   繁体   English

使用 std::cout 显示无法按预期工作

[英]Display using std::cout not work as expected

So I'm trying to make a school schedule that'd have text on the right side with text of a string I declared as laikas[7] .因此,我正在尝试制定一个学校时间表,该时间表的右侧有文本,其中包含我声明为laikas[7]的字符串文本。 Note that it's in my native language (Lithuanian).请注意,它是我的母语(立陶宛语)。 My code is:我的代码是:

cout << " 1) Vokieciu\n" << laikas[0] << "2) Biologija\n" << laikas[1] << "3) Vokieciu\n" << laikas[2] << "4) Daile\n 5)" << laikas[3] << "Lietuviu\n" << laikas[4] << "6) Fizinis\n" << laikas[5] << "7) Anglu\n" << laikas[6];

The string:字符串:

string laikas[7] {"08:00", "08:55", "09:50", "11:05", "12:00", "12:55", "13:50"};

Yet the output is:然而输出是:

08:002) Biologija
08:553) Vokieciu
09:504) Daile
 5)11:05Lietuviu
12:006) Fizinis
12:557) Anglu
13:50

Any way to get the time on the right side?有什么方法可以让时间正确? So for example it'd be 2) Biologija 08:00所以例如它会是 2) Biologija 08:00

your new line should come after the laikas part, and adding a couple of tabs will make it look prettier aswell :)你的新行应该在 laikas 部分之后,添加几个标签也会让它看起来更漂亮:)

int main() {
    // your code goes here
    string laikas[7] {"08:00", "08:55", "09:50", "11:05", "12:00", "12:55", "13:50"};

    cout << "\n1) Vokieciu\t" << laikas[0] << "\n2) Biologija\t" << laikas[1] << "\n3) Vokieciu\t" << 
    laikas[2] << "\n4) Daile\t" << laikas[3] << "\n5)Lietuviu\t" << laikas[4] << "\n6) Fizinis\t" << 
    laikas[5] << "\n7) Anglu\t" << laikas[6] << endl;
    return 0;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM