gpt4 book ai didi

c++ - 退出简单的 while 循环时遇到问题

转载 作者:行者123 更新时间:2023-11-27 22:36:57 25 4
gpt4 key购买 nike

<分区>

所以我正在尝试编写一个程序,从用户那里获取值,并且应该在用户输入 q 后停止,但由于某种原因,这个程序不工作,即使在我用 q 或 Q 进行测试后,程序也不会停止运行。

vector <string> names;
vector <int> ticPurch;

int numOfRaff;
string nameOfpart;

cout << "Enter the name of the participant, enter q to quit " << endl;
cin >> nameOfpart;

while(nameOfpart != "q" || nameOfpart != "Q"){

names.push_back(nameOfpart);
cout << "Please enter the number of tickets the participant bought " << endl; //Getting input and storing them in vector
cin >> numOfRaff;
ticPurch.push_back(numOfRaff);
cout << endl;
cout << "Enter the name of the participant, enter q to quit " << endl;
cin >> nameOfpart;

}

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