一些代码强制用户输入选项 我对C++非常陌生,我需要一些代码的帮助来强迫用户做出选择。第一个选项调用main函数,第二个选项调用return0,否则程序不会在任何选项的main函数中返回0。选择Y或Y表示是,选择n或n表示否,除了这些字母外,代码不接受任何字母。 如果我能得到帮助,我将不胜感激,谢谢 #include "person. h" #include <iostream> #include <string> using namespace std; int main() { person persons; persons. getInfo(); persons.showInfo(); cout << "do you want to continue, type Y or y for yes and n or N for no to exit" << endl; char choice; cin >> choice; if (choice == ("Y"||"y")) { int main(); } if (choice == ("N"||"n")) { return 0; } else { cout << "please make a choice"; cin >> choice; } /* This is where I would like to iterate in other for the user to make one of the choices provided above */ return 0; }
您可以采用以下方式:一些代码强制用户输入选项 我对C++非常陌生,我需要一些代码的帮助来强迫用户做出选择。第一个选项调用main函数,第二个选项调用return0,否则程序不会在任何选项的main函数中返回0。选择Y或Y表示是,选择n或n表示否,除了这些字母外,代码不接受任何字母。 如果我能得到帮助,我将不胜感激,谢谢 #include "person. h" #include <iostream> #include <string> using namespace std; int main() { person persons; persons. getInfo(); persons.showInfo(); cout << "do you want to continue, type Y or y for yes and n or N for no to exit" << endl; char choice; cin >> choice; if (choice == ("Y"||"y")) { int main(); } if (choice == ("N"||"n")) { return 0; } else { cout << "please make a choice"; cin >> choice; } /* This is where I would like to iterate in other for the user to make one of the choices provided above */ return 0; },c++,C++,您可以采用以下方式: if(choice == "Y" || choice == "y") int main(); else return 0; 因此,他们必须放置Y或Y继续,然后任何其他内容都将终止程序,返回0 给我你是认真的吗?请转到以了解您可以在此处询问的问题。有关..的帮助?你能展示你的代码让我们帮你吗?强迫用户只需雇佣一个执行者。
if(choice == "Y" || choice == "y")
int main();
else
return 0;
因此,他们必须放置Y或Y继续,然后任何其他内容都将终止程序,返回0 给我你是认真的吗?请转到以了解您可以在此处询问的问题。有关..的帮助?你能展示你的代码让我们帮你吗?强迫用户只需雇佣一个执行者。