第八章单元测试
  1. 有如下的结构体定义语句:struct student{ int num }; 则能正确定义结构体变量的语句是( )。

  2. A:struct s1; B:struct student s1; C:struct student; D:student s1;
    答案:struct student s1;
  3. 有如下的结构体定义语句:struct student{ int num }; 则能正确定义结构体数组的语句是( )。

  4. A:struct student s[5]; B:struct s[5] student; C:struct student (5); D:struct student s[];
  5. 如下程序的输出是( )。
    #include <stdio.h>
    #include <string.h>
    struct stud{ char name[10]; int score[2]; };
    int main()
    { int i = 0;
    struct stud t[4]={{ "Lisa",98,87}, {"Tom",89,86}, {"John",68,79}, {"Lili",94,90} };
    printf("%s \n", t[1].name);
    return 0;
    }

  6. A:Tom B:Lisa C:John D:Lili
  7. 设有如下定义,则能输出'Z'的语句是( )。
    struct person{ char name[9]; int age; };
    struct person class[10]={ "Wang" , 17, "Zha n g" ,19, "M i n g" , 18, "L i u" , 20 };

  8. A:printf("%c\n",class[ 1 ].name[ 0] ); B:printf("%c\n",class[ 2 ].name[ 1] ); C:printf("%c\n",class[ 2 ].name ); D:printf("%c\n",class[ 1 ].name[ 1] );
  9. 已知如下语句:
    struct date{int y, m, d;};
    struct student
    { int num;
    char name[9];
    struct date bir;
    } stu, *p=&stu;
    则错误的表达式是( )。

  10. A:p->bir.y B:p->bir->y C:stu.bir.y D:stu.name
  11. 以下程序的输出是( )。
    #include <stdio.h>
    struct st
    { int num;
    char name[10];
    int age;
    }x[3]={{1,”zhang”,19},{2,”li”,20},{3,”wang”,21}},*p=x;
    int main()
    { printf(“%s, %d\n”,(p+2)->name, (*p).age);
    return 0;
    }

  12. A:li, 21 B:zhang, 20 C:wang, 19 D:li, 20
  13. 当定义一个结构体变量时,系统为它分配的内存空间是结构中各成员所需内存容量之和。( )

  14. A:对 B:错
  15. 有如下的结构变量定义语句:struct student{ int num} stu; 则结构类型名为stu。( )

  16. A:错 B:对
  17. 结构体成员的类型必须是基本数据类型。( )

  18. A:对 B:错
  19. p为指向结构体的指针,则 (*p).成员名 与 p->成员名 是等价的。( )

  20. A:对 B:错

温馨提示支付 ¥3.00 元后可查看付费内容,请先翻页预览!
点赞(4) dxwkbang
返回
顶部