爪哇。 “输入”作为新行,不提交

发布于 2024-12-18 12:29:29 字数 124 浏览 1 评论 0原文

如何

1 2  
4 5 4 2 3  
1 2 1 1 1

在cmd中输入? 我不希望在按“Enter”时读取“1 2”,而是转到下一行并写入“4 5 4 2 3”

how to input

1 2  
4 5 4 2 3  
1 2 1 1 1

to cmd?
I don't want "1 2" to be read when I press "Enter" but to go to next line and write "4 5 4 2 3"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

零時差 2024-12-25 12:29:29

我只是在这里做猜测,因为你确实没有给我太多的帮助,但是你是否考虑过使用转义字符 () 来转义换行符?

或者,只需创建一个循环,继续读取,直到输入空行:

string line;
do {
    cin >> line;
} while (line.size() > 0);

I'm just doing guesses here, since you really didn't give me much to work with, but did you consider using the escape character () to escape newlines?

Alternatively, just create a loop that keeps reading until you enter an empty line:

string line;
do {
    cin >> line;
} while (line.size() > 0);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文