• 第五章 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;
    }
    

      

  • 相关阅读:
    Linux下套接字具体解释(九)---poll模式下的IO多路复用server
    【零基础学习iOS开发】【02-C语言】08-基本运算
    用python合并N个不同字符集编码的sql文件的实践
    小木虫emuch遭封禁,新域名muchong.com尚可用
    DB2中编目本机其中数据库的方法
    php socket 处理只是来数据流,该怎样避免(好像是堵塞了)
    Submission Details [leetcode] 算法的改进
    Qt Installer Framework的学习
    CI如何在子目录下可以设置默认控制器
    php CI 实战教程:如何去掉index.php目录
  • 原文地址:https://www.cnblogs.com/xiangxiaodong/p/2552898.html
Copyright © 2020-2023  润新知