我不知道如何通过仅在我点击“n”或“N”时关闭来无限期地继续循环...一旦我放入任何东西它最终会关闭,那么我该如何回到循环中?
int counter = 5;
while(counter > 1)
linear(xcoordinateone, xcoordinatetwo, ycoordinateone, ycoordinatetwo, slope, intercept); //calling
{
cout<<"The points you entered define the function: y = " << slope << xone << "+" << intercept;
cout << "\n Do you want to continue?";
if (answer == 'N' || answer == 'n');
cin >> answer;
return 0;
}
最佳答案
您可以在 while 循环中使用多个条件:
answer = 'y';
while(answer != 'N' && answer != 'n'){
cout << "\n Do you want to continue?";
cin >> answer;
}
关于c++ - While 循环和 If 语句和函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33659744/