zoukankan      html  css  js  c++  java
  • 第七章 循环语句 简单

    /*
    // 1 循环语句的老祖宗Goto语句
    #include <iostream>
    using namespace std;
    int main()
    {
         int i= 1;
    	 if(i > 10){
    	     //goto yes;
    	 }
    	 cout<<"*"<<i<<endl;
    	 i++;
    	 //goto yes;
    	 cout<<"程序结束";
    	 cout<<"********\n";
    yes:;
    	 return 0;
    }
    */
    
    
    /*
    // 2 while语句
    #include <iostream>
    using namespace std;
    int main()
    {
        int i=1;
    	while(i < 10)
    	{
    	    cout<<"i:"<<i<<endl;
    		i++;
    	}
    	return 0;
    }
    */
    
    
    /*
    // 3 while语句的其它用法
    #include <iostream>
    using namespace std;
    int main()
    {
    	int number, dot=1;
    	cout<<"请问你想看几次:"<<endl;
    	cin>>number;
    	while(dot <= number)
    	{
    	    cout<<"问君能有几多愁,恰似一江春水向东流"<<endl;
    		dot++;
    	}
    	cout<<"程序运行结束"<<endl;
    	
    
        return 0;
    }
    
    */
    
    /*
    // 4 continue和break语句
    #include <iostream>
    using namespace std;
    int main()
    {
    	int i=0;
    	int b = 10;
    	while(i < b )
    	{
    		i++;
    		if(i == 8){
    		    cout<<"这里进行跳出while循环"<<endl;
    			break;
    		}
    		if(i==2){
    		   cout<<"这里只是跳出本次循环2"<<endl;
    		   continue;
    		}
    		
    		cout<<"i的值为:"<<i<<endl;
    	}
        return 0;
    }
    */
    
    /*
    // 6 do...while循环
    #include <iostream>
    using namespace std;
    int main()
    {
    	int number;
    	cout<<"请问您要看几次:"<<endl;
    	cin>>number;
    	int dot=0;
    	do{
    		 cout<<"这是第"<<number<<"次循环"<<endl;
    	     dot ++;
    	}while(dot <  number);
        return 0;
    }
    */
    
    /*
    //7 for循环
    #include <iostream>
    using namespace std;
    int main()
    {
    	int number, dot=0;
    	cout<<"请问您要看几次:"<<endl;
    	cin>>number;
    	for(int i=number; i>0; i--)
    	{
    	   cout<<"这是第"<<i<<"次操作"<<endl;
    	}
    
        return 0;
    }
    */
    
    //8 灵活的for循环
    #include <iostream>
    using namespace std;
    int main()
    {
    	for(int i=0, x=0,y=0; x<= 3; i++,x++,y++)
    	{
    	    cout<<"i="<<i<<", x="<<x<<", y="<<y<<endl;
    	}
        return 0;
    }
    

      

  • 相关阅读:
    一个access连接的处理
    小说
    web版的outlook和project的结合,再和sns 结合,形成组织之间的一个共享信息.还有更多应用
    今天研究了一下window pe
    IMX6ULL开发板文本编辑工具
    Create class and methods in x++
    Image in AX 2009
    IP and userId dislay in AX 2009 title
    helpless....
    about Posted & Unposted of button function
  • 原文地址:https://www.cnblogs.com/xiangxiaodong/p/2552903.html
Copyright © 2011-2022 走看看