4.变量说明的意义是什么?下面的说明正确吗? char c1,c2,c3=“10;/正确 int k1=k2=k3=0;错误,必须逐个赋初值* / int kI=0,k2=0,k3=0;* float x1=l: V=0 同时说明的变量用逗号分隔 double a=le-5b /说明语句应以分号结尾
4. 变量说明的意义是什么?下面的说明正确吗? char c1,c2,c3=‘\0’; /*正确*/ int k1=k2=k3=0; /*错误,必须逐个赋初值*/ /* int k1=0,k2=0,k3=0; */ float x1=1; y=0; double a=1e-5,b /*说明语句应以分号结尾*/ 同时说明的变量用逗号分隔
6.设i,j是整型,a浮点,判断下列表达式是否正确: (1)(17/15)%3(正确) (2)a&0377(正确) (3)(i%j)=B’(正确) (8)(a=)>=0?a:-a(正确) (9) double(i+j)(错误)( double)(i+j (10)ij&&a(正确)
6. 设i,j 是整型,a浮点,判断下列表达式是否正确: (1) (17/15) %3 (正确) (2) a &0377 (正确) (3) (i%j) =‘B’ (正确) (8) (a=i*j) >=0 ? a: -a (正确) (9) double(i+j) (错误) (double)(i+j) (10) i^j && a (正确)
7 unsigned short i=013,j=0x13, k=0, a, b, c, d; short e,f 给出下列表达式的结果和类型: 结果 类型 a- 0 unsigned short (2)i! int (3)!k unsigned short (5)i^j
7 unsigned short i=013,j=0x13,k=0,a,b,c,d; short e ,f; 给出下列表达式的结果和类型: 结果 类型 (1) a=i==j 0 unsigned short (2) i!=j 1 int (3) !k 1 int (4) b=!i 0 unsigned short (5) i^j
(5)ij 1514131211109876543210 0000000000001011 1514131211109876543210 00000000000100 11 15141312111098765432 00000000000 10 0 结果:24 类型:int
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 (5) i^j 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 结果: 24 类型: int
(6)c=ilj 1514131211109876543210 0000000000001011 1514131211109876543210 00000000000100 11 15141312111098765432 0000000000011011 结果:27 类型: unsigned short
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 (6) c=i | j 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 结果: 27 类型: unsigned short
(7)d 151413121110 8765432 1111111111110100 结果:65524 类型: unsigned short (8)~k 结果:-1 类型: unsigned int(16) n (32)
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 (7) d=~i 结果: 65524 类型: unsigned short (8) ~k 结果: -1 类型: unsigned int (16) int (32)
(9) 151413121110 8765432 1111111111110100 1514131211109876543210 0000000000001011 15141312111098765432 0000000000001100 结果:-12 类型: short
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 (9) e=~i 结果: -12 类型: short 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0
(10)fk 151413121110 8765432 11111111111111 结果:-12 类型: short (11)k+?i:j结果:0x13 类型: unsigned int (12)i+=i结果:014 类型: unsigned int
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 (10) f=~k 结果: -12 类型: short (11) k++? i : j 结果: 0x13 类型: unsigned int (12) i++,j=i 结果: 014 类型: unsigned int
8. int k0. mn: (1)n=k++,m=(k*=2) m:2 n:0 (2)n=0,-n,n+=(n++)-n n 0 n=n+(n++)-n=-1+(-1)-(-1)=-1
8.int k=0,m,n; (1) n=k++, m=(k*=2) k: 2 m: 2 n: 0 (2) n=0,--n,n+=(n++) –n n: 0 n=n+(n++) –n=-1+(-1)-(-1)= -1