#include
#include
#include
using namespace std;
int main(int argc,char *argv[])
{
char ch;
for(int i=0;;i++)
{
cout <<"Enter:(Y-continue,N-exit):";
cin >>ch;
if(ch == 'N')
{
return 0;
}
else if(ch == 'Y')
{
continue; //换成要执行的代码
}
}
system("PAUSE");
return EXIT_SUCCESS;
}
仅供参考
这样:
char a = 'Y';
...
do
{
...
cout<<"please input 'Y' or 'N'";
}whlie(getchar() == a);