我在编码方面很陌生(大约2周后),并且我一直在尝试使程序无法进行练习,所以不要对我太粗鲁:D。我今天尝试的是制作一个需要插入字母的程序,因为我一直在使用int函数,因此我想对其进行一些更改。
因此,我一直在尝试使此工作正常进行,尽管它执行程序,但是当您键入字母时,它只会关闭程序。感谢您的帮助,如果您能解释我的错误。谢谢大家!! :D
#include <iostream>
int main()
{
char Answer;
char responsetype;
std::cout<<"Please rate this app\n";
std::cin>> Answer;
while (responsetype=false)
if (Answer=='Y')
{
responsetype=true;
std::cout<< "Thanks for rating :D\n";
}
else if (Answer/='Y')
{
if (Answer=='N')
{
responsetype=true;
std::cout<< "awwww... Okay then.. :(\n";
}
else(true);
responsetype=false;
std::cout<<"You need to answer Y or N :/\n";
}
return 0;
最佳答案
我已经改变的事情:
#include <iostream>
int main() {
char Answer;
bool responsetype = false;
std::cout<<"Please rate this app\n";
std::cin>> Answer;
while (!responsetype){
switch(Answer)
{
case 'Y':
responsetype=true;
std::cout<< "Thanks for rating :D\n";
break;
case 'N':
responsetype=true;
std::cout<< "awwww... Okay then.. :(\n";
break;
default:
responsetype=false;
std::cout<<"You need to answer Y or N :/\n";
}
}
getchar(); // Asks for another input before closing console
return 0;
}
关于c++ - 是或否程序,用于请求对应用程序进行评级的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62614887/