• [C puzzle book] operators


    #include <stdio.h>
    
    int main(void)
    {
        int x;
        x = -3 + 4 * 5 -6; printf("%d\n",x);
        x = 3 + 4 % 5 - 6; printf("%d\n",x); //How to get it?
        x = -3 * 4 % - 6 / 5; printf("%d\n",x);
        x = (7 + 6) % 5 / 2; printf("%d\n",x);
    
    
    }


     1 #include <stdio.h>
     2 #define PRINT(int) printf("%d\n",int)
     3 
     4 int main(void)
     5 {
     6     int x,y,z;
     7     x=2; y=1; z=0;
     8     x=x&&y||z; PRINT(x);
     9     PRINT(x|| !y && z);
    10     x = y =1;
    11     z =x++ -1; PRINT(x); PRINT(z);
    12     z += -x++ + ++y; PRINT(x); PRINT(z);
    13     z = x / ++ x; PRINT(z);
    14 
    15 
    16 }
     
    #include <stdio.h>
    #define PRINT(int) printf("int = %d\n",int)
    
    int main(void)
    {
        int x, y, z;
        x = 03; y = 02; z = 01;
        PRINT(x | y & z);
        PRINT(x | y & -z);
        PRINT(x ^ y & -z);
        PRINT(x & y && z);
    
        x=1; y = -1;
        PRINT(! x | x);
        PRINT(~ x | x);
        PRINT(x ^ x);
        x <<= 3; PRINT(x);
        y <<= 3; PRINT(y);
        y >>= 3; PRINT(y);
    
    }
    

     

     1 #include <stdio.h>
     2 //#define PRINT(int) printf("int = %d\n",int)
     3 #define PRINT(int) printf(#int" = %d\n",int)
     4 //Why add the # to get the right answer????
     5 int main(void)
     6 {
     7     int x =1, y = 1, z = 1;
     8     x += y += z;
     9     PRINT(x<y? y : x);
    10     PRINT(x < y ? x++ : y++);
    11     PRINT(x); PRINT(y);
    12     PRINT(z += x <y? x++ : y++);
    13     PRINT(y); PRINT(z);
    14     x=3; y=z=4;
    15     PRINT((z >= y >= x) ? 1 : 0);
    16     PRINT( z >= y && y>= x);
    17 }
     1 #include <stdio.h>
     2 #define PRINT3(x,y,z) printf("x=%d\ty=%d\tz=%d\n",x,y,z)
     3 
     4 int main(void)
     5 {
     6     int x, y, z;
     7     x = y = z =1 ;
     8     ++x || ++y && ++z; PRINT3(x,y,z);
     9     x = y = z =1 ;
    10     ++x && ++y || ++z; PRINT3(x,y,z);
    11     x = y = z =1 ;
    12     ++x && ++y && ++z; PRINT3(x,y,z);
    13     x = y = z = -1 ;
    14     ++x && ++y || ++z; PRINT3(x,y,z);
    15     x = y = z = -1 ;
    16     ++x || ++y && ++z; PRINT3(x,y,z);
    17     x = y = z = -1 ;
    18     ++x && ++y && ++z; PRINT3(x,y,z);
    19 
    20 }
  • 相关阅读:
    解决docx4j 变量替换 由于变量存在样式式或空白字符 导致替换失败问题
    redis批量删除key 远程批量删除key
    idea 集成sonarLint检查代码bugs
    mac jmeter 的使用
    tomcat配置管理员-走后门
    终端mysql Operation not permitted错误解决方案
    update使用inner join
    hibernate 三种状态的转换
    数据库中间表插入乱序
    解决https证书验证不通过的问题
  • 原文地址:https://www.cnblogs.com/abacuspix/p/2584991.html
Copyright © 2020-2023  润新知