21天学通c++之7.4 continue与break应用

#include <iostream>
using namespace std;
int main(){
 unsigned short small;
 unsigned long large;
 unsigned long skip;
 unsigned long target;
 const unsigned short MAXSMALL=65535;
 cout<<"enter s small number: ";
  cin>>small;
 cout<<"enter s large number: ";
  cin>>large;
 cout<<"enter s skip number: ";
  cin>>skip;
 cout<<"enter s target number: ";
  cin>>target;
 cout<<"\n";

 while(small<large&&small<MAXSMALL)
 {
  small++;
  if(small%skip==0)
  {
  cout<<"skipping on "<<small<<endl;
  continue;//跳到循环的开通
  }
  if(large==target)
  {
  cout<<"targer reached!";
   break;
  }
  large-=2;
 }
 cout<<"\nsmall:"<<small<<"large: "<<large<<endl;
 return 0;
}

posted @ 2008-11-21 21:51  雨城  阅读(407)  评论(0编辑  收藏  举报