#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 }