第九章单元测试
  1. 有以下结构体定义:

    struct example

    { int x;

    int y; }v1;

    则正确的引用或定义是(      


  2. A:struct example v2={10}; B: v1.x=10; C:example v2; v2.x=10; D:struct v2; v2.x=10;   
    答案: v1.x=10;
  3. 对于如下结构体定义,若对变量person的出生年份进行赋值,正确的赋值是(      

    struct date

    { int year,month,day; 

    };

    struct worklist

    { char name[20];

      char sex;

      struct date birth;

    }person;


  4. A:birth.year=1976    B:person.birth.year=1976    C: year=1976     D:person.year=1976
  5. 根据下述定义,可以输出字符'A'的语句是     

    struct person

    { char name[11];

    struct 

    { char name[11];

        int age;

    }other;

    };

    struct person man[10]={ {"Jone",{"Paul",20}},{"Paul",{"Mary",18}},

    {"Mary",{"Adam",23}},{"Adam",{"Jone",22}}

    };


  6. A:printf("%c",other.name[0]); B:printf("%c",man[3].name); C:printf("%c",man[2].(* other[0])); D:printf("%c",man[2].other.name[0]);
  7. 若有以下程序段:

    struct st

    { int n;

    struct st *next; };

    struct st a[3]={5,&a[1],7,&a[2],9, '\0'} ,*p=a;

    则值为6的表达式为     




  8. A: (*p).n++   B:++p->n C:p++->n     D:p->n++  
  9. 运行下列程序段,输出结果是(     

      struct country

          { int num;

            char name[10];

           }x[5]={1,"China",2,"USA",3,"France",4, "England",5, "Spanish"};

      struct country *p;

      p=x+2;

       printf("%d,%c",p->num,(*p).name[2]);




  10. A:2,USA B:4,g    C: 5,Spanish D:3,a
  11. 定义以下结构体数组

      struct c

         { int x;

           int y;

          }s[2]={1,3,2,7};

    语句printf("%d",s[0].x*s[1].x)的输出结果为(      




  12. A: 6 B:21 C:2 D:14 
  13. 定义以下结构体类型

    struct  student

    {char  name[10];

    float score[50];

    double average;

    }stud1;

    stud1占用内存的字节数是   



  14. A:7 B:228 C:64 D:218
  15. 能在一个存储区内处理不同的类型的数据叫结构



  16. A:对 B:错
  17. 在编译时对结构类型不分配空间,只能对结构体变量分配空间。



  18. A:错 B:对
  19. 结构一旦定义,系统就给它分配所需的内存单元。



  20. A:错 B:对

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