do-while()用法

do-while()循环适合于运用在交互程序中,

 

  
  
  
  
  1. d0-while()循环妙用  
  2.  do   
  3.  {          int val1,val2;  
  4.      cout<<"please enter  two values";  
  5.      cin>>val1>>val2;  
  6.      cout<<"The sum of "<<val1<<"and"<<val2 
  7.          <<"="<<val1+val2<<"\n\n\n"  
  8.          <<"More ? [yes][no]";  
  9.      cin>>rsp;  
  10.  
  11.  }while(!rsp.empty()&&rsp[0]!='n'); 

 

你可能感兴趣的:(do-while)