zoukankan      html  css  js  c++  java
  • 第五章 IF语句与逻辑运算符 简单

    /*
    // 4 什么是表达式
    #include <iostream>
    using namespace std;
    int main()
    {
    	for(int i=0; i<=60; i++)
    	{
    		if(i%6 == 0)
    		{
    		   cout<<"\n";
    		}
    		cout<<i<<"\t";
    	}
        return 0;
    }*/
    
    /*
    // 5 赋值运算符与数学运算符
    #include <iostream>
    using namespace std;
    int main()
    {
    	int a=2;
    	a = a *= 6;
    	cout<<a<<endl;
        return 0;
    }
    */
    
    /*
    // 6 什么是自加与自减
    #include <iostream>
    using namespace std;
    int main()
    {
    	int a = 1;
    	cout<<a++<<endl;
    	cout<<a<<endl;
    
    	int b = 11;
    	cout<<b--<<endl;
    	cout<<b<<endl;
        return 0;
    }
    */
    
    /*
    // 7 表达式的优先级
    #include <iostream>
    using namespace std;
    int main()
    {
    	int a = (1+2)*(3+4)*5;
    	cout<<a<<endl;
        return 0;
    }
    */
    
    /*
    // 8 关系运算符
    #include <iostream>
    using namespace std;
    int main()
    {
    	int x = 1, y = 2;
    	if(x >= y){
    	    cout<<x<<endl;
    	}else{
    	    cout<<y<<endl;
    	}
        return 0;
    }
    */
    
    /*
    //9 if语句
    #include <iostream>
    using namespace std;
    int main()
    {
    	int x = 3, y=2;
    	if(x<y)
    	{
    	    cout<<"x不等于y\n";
    		cout<<"y大于x\n";
    		cout<<"x小于y\n";
    	}
    	cout<<"x不等于0\n";
        return 0;
    }
    */
    
    /*
    //10 else语句
    #include <iostream>
    using namespace std;
    int main()
    {
    	int a, b;
    	cout<<"请输入第一个值:"<<endl;
    	cin>>a;
    	cout<<"请输入第二个值:"<<endl;
    	cin>>b;
    	if(a>b)
    	{
    	   cout<<"第一个数比第二个数大"<<endl;
    	}else{
    	   cout<<"第二个数比第一个数大"<<endl;
    	}
    	cout<<"该程序执行完毕"<<endl;
    
        return 0;
    }
    */
    
    /*
    //12 if语句的嵌套
    #include <iostream>
    using namespace std;
    int main()
    {
        cout<<"请佃入一个整数:"<<endl;
    	int x;
    	cin>>x;
    	if(x > 1)
    	{
    	     if(x<100)
    			 cout<<"x大于1小于100"<<endl;
    		 else
    			 cout<<"x大于或者等于100"<<endl;
    	}else{
    	     if(x<1)
    			 cout<<"x小于1"<<endl;
    		 else
    			 cout<<"x等于1"<<endl;
    	}
    }
    */
    
    
    /*
    //16 逻辑非运算符
    #include <iostream>
    using namespace std;
    int main()
    {
       cout<<"请输入一个大于1的整数:"<<endl;
       int x;
       cin>>x;
       if(!x==0){
          cout<<"x不等于0"<<endl;
       }else{
          cout<<"x等于0"<<endl;
       }
       return 0;
    }
    */
    
    // 18 运算式的真假关系
    #include <iostream>
    using namespace std;
    int main()
    {
    	char a ='\0';
    	if(!a)
    	{
    	    cout<<"a的值为0"<<endl;
    	}else{
    	    cout<<"a的值不为0"<<endl;
    	}
        return 0;
    }
    

      

  • 相关阅读:
    根据NSString字符串长度自动改变UILabel的frame
    计算两个日期的天数问题
    iOS学习笔记(02)
    iOS学习笔记(01)
    iOS使用Swift语言检查并提示更新
    iOS的一些关键字
    一些常见warning的原因和解决方法
    Objective-C和Swift实现单例的几种方式
    与导航栏下控件的frame相关的edgesForExtendedLayout、translucent、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets等几个属性的详解
    App常见崩溃问题分析
  • 原文地址:https://www.cnblogs.com/xiangxiaodong/p/2552898.html
Copyright © 2011-2022 走看看