本文介绍了如何在循环后重新开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
int main()
{//在循环过程中,我的程序将跳过此部分,直接从第二个 段开始。
cout<< 嘿那里,我该怎么称呼你? << ENDL;
getline(cin,name);
system(cls);
cout<< 嘿<<名称<< 今天我会帮你计算一次往返需要支付的汽油费。
system(暂停);
system(cls);
Info();
Graphics();
system(暂停);
bool input = 1;
while(输入)
{
char choice;
cout<< 你想再试一次吗?(y / n)<< ENDL;
cin>>选择;
开关(选择)
{
案例'y':
输入= 0;
main();
返回0;
休息;
case'n':
cout<< huehuehuehuehue bye!;
输入= 0;
休息;
默认值:
cout<< 输入无效。 << ENDL;
输入= 1;
休息;
}
}
}
我尝试过:
我什么都没试过。
解决方案
int main() { //During loop, my program will skip this section and start straight from second paragraph. cout << "Hey there, what shall i call you?" << endl; getline(cin,name); system("cls"); cout << "Hey " << name << ".\nToday I will help you on calculating the cost of petrol you need to pay for a round trip.\n"; system("pause"); system("cls"); Info(); Graphics(); system("pause"); bool input = 1; while(input) { char choice; cout << "Do you want to try again? (y/n)" << endl; cin >> choice; switch(choice) { case 'y': input = 0; main(); return 0; break; case 'n': cout << "huehuehuehuehue bye!"; input = 0; break; default : cout << "invalid input." << endl; input = 1; break; } } }
What I have tried:
I have tried nothing.
解决方案
这篇关于如何在循环后重新开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!