gpt4 book ai didi

c++ - (C++) 循环 : User Input Without Reserving Memory

转载 作者:行者123 更新时间:2023-11-30 01:57:58 26 4
gpt4 key购买 nike

有没有一种方法可以让用户连续输入一堆整数,但是当她/他完成后她/他会在完成时按 -111(必须是这个数字)而不必初始化另一个数据类型?

像这样:

while(用户输入的不是-111)

最佳答案

这个怎么样

  int i;   
do {
std::cin >> i;
} while (i != -111);

关于c++ - (C++) 循环 : User Input Without Reserving Memory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18006674/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com