举一反三
- 下列程序的输出结果是( )。 struct abc{ int a; float b; char c[10]; } int main() { static struct abc x={23, 98.53, “wang”}; struct abc *px= &x; printf(“%d %.1f %s ”, x.a, x.b, x.c ); printf(“%d %.1f %s ”, px->a, (*px).b, px->c); printf(“%c %s”, *px->c+2,&px->c[1]); }
- struct abc {int a,b,c;}; void main(){ struct abc s[2]={{1,2,3},{4,5,6}}; int t; t=s[0].a+s[1].b; printf("%d\n",t); }
- 以下结构体说明和变量定义中,正确的是( )。 A: struct abc{ int n;double m );struct abc x, y; B: struct ABC{ int n;double m; }struct ABC x, y; C: typedef struct abc{ int n;double m; }ABC;ABC x,y; D: D) struct abc{ int n;double m; };abc x,y;
- 以下结构体说明和变量定义中,正确的是( ) A: typedef struct abc{ int n;double m; }ABC;ABC x,y; B: struct abc{ int n;double m };struct abc x, y; C: struct ABC{ int n;double m; }struct ABC x, y; D: struct abc{ int n;double m; };abc x, y;
- 下列程序的输出结果为_________。 #include struct abc { char c; float v; }; void main() { abc a={'B',98.5}; cout
内容
- 0
若有如下定义语句:int x;则经过( )后,语句*px=0;,可将x值置为0。 A: int *px; B: int *px=&x; C: float *px; D: float *px=&x;
- 1
有以下程序段:#include int main(){int x[ ] = {10, 20, 30}; int *px = x;printf("%d, ", ++*px); printf("%d, ", *px); px = x;printf("%d, ", (*px)++); printf("%d, ", *px); px = x;printf("%d, ", *px++); printf("%d, ", *px); px = x;printf("%d, ", *++px); printf("%d\n", *px);return 0;}程序运行后的输出结果是( ) A: 20, 10, 11, 10, 11, 10, 11, 10 B: 11, 11, 11, 12, 12, 20, 20, 20 C: 20, 10, 11, 20, 11, 12, 20, 20 D: 11, 11, 11, 12, 12, 13, 20, 20
- 2
写出下列程序运行结果 #include “stdio.h” void swap(int *px , int *py ); void main() { int a,b; a=5; b=10; printf(“ before swap a=%d, b=%d ”,a,b); swap(&a,&b); printf(“after swap a=%d, b=%d ”,a,b); } voidswap(int *px , int *py ) { int temp; temp=*px; *px=* py; *py=temp; printf(“ in swap x=%d,y=%d ”,*px, *py); }
- 3
函数f()定义如下,该函数返回值的数据类型是______。 struct ABC int a;int b;int c;; struct ABC *f(struct ABC abc[2]) return (abc);
- 4
有以下程序段:#include stdio.hint main(){int x[ ] = {10, 20, 30}; int *px = x;printf(%d, , ++*px); printf(%d, , *px); px = x;printf(%d, , (*px)++); printf(%d, , *px); px = x;printf(%d, , *px++); printf(%d, , *px); px = x;printf(%d, , *++px); printf(%d\n, *px);return 0;}程序运行后的输出结果是( )。 A: 11, 11, 11, 12, 12, 20, 20, 20 B: 20, 10, 11, 10, 11, 10, 11, 10 C: 11, 11, 11, 12, 12, 13, 20, 20 D: 20, 10, 11, 20, 11, 12, 20, 20