PTA ---结构错题汇总

1,

struct stu{
  int x; 
  int *y;
} *p;
int dt[4] = {10, 20, 30, 40};
struct stu a[4] = {50, &dt[0], 60, &dt[1], 70, &dt[2], 80, &dt[3]};

int main( )
{ 
   p=a;
   printf("%d,", ++p->x); //p->x 值为50,之后++50==51
   printf("%d,", (++p)->x);//(++p)表达式值为a[1],同时p向之后移一个单位。之后a[1]-->x 值为60
   printf("%d", ++(*p->y));//p->y 值为&dt[1],++20==21

   return 0;
}

输出:
51,60,21

2,如果结构变量s中的生日是“1984年11月11日”,下列对其生日的正确赋值是(A

struct student
{  
  int no;
  char name[20];
  char sex;
  struct{
    int year;
    int month;
    int day;
  }birth;
};
struct student s;


---------------------------
struct add {
  int year;
  int month;
  int day;
};

struct student
{  
  int no;
  char name[20];
  struct add birth;
  char sex;

};
struct student s;

A.s.birth.year = 1984; s.birth.month = 11; s.birth.day=11;

B.birth.year = 1984; birth.month = 11; birth.day = 11;

C.s.year = 1984; s.month = 11; s.day = 11;

D.year = 1984; month = 11; day = 11;

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值