要定义整型数组x,使之包括初值为0的三个元素,下列语句中错误的是( )
A: int x[3]={0,0,0};
B: int x[ ]={0};
C: int x[3]={0};
D: int x[ ]={0,0,0};
A: int x[3]={0,0,0};
B: int x[ ]={0};
C: int x[3]={0};
D: int x[ ]={0,0,0};
举一反三
- 设有定义:int x[2][3];,则可以用语句x[0]=0;为数组所有元素赋初值0。(1.0分)
- 下列数组定义中错误的是_______ () A: int x[ ]={0}; B: int x[1]={0}; C: int x[ ][ ]={{1,2,3},{4,5,6}}; D: int x[2][3]={1,2,3,4,5,6};
- 以下在定义数组a的同时,给a数组中元素赋初值0,正确的是( )。 A: int a[3]={0}; B: int a[3]=[0]; C: int a[3]=(0,0,0); D: int a[3]={5,0};
- 以下将数组中的元素全部置0的操作错误的是( ) A: int a[3];a={0}; B: int a[3]={0}; C: int a[3]={0,0,0}; D: int a[3];a[0]=a[1]=a[2]=0;
- 如果要实现计算x绝对值的功能,下面程序有错误的是? A: int fun(int x){ if(x<0) return -x;<br> return x; } B: int fun(int x){ if(x<0) return -x;<br> else return x; } C: int fun(int x){ if(x<0) return -x;<br> if(x>0) return x; } D: int fun(int x){ if(x<0) return -x;<br> else if(x==0) return x; else return x; }