PTA ---结构错题汇总
生活随笔
收集整理的這篇文章主要介紹了
PTA ---结构错题汇总
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
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==51printf("%d,", (++p)->x);//(++p)表達(dá)式值為a[1],同時(shí)p向之后移一個(gè)單位。之后a[1]-->x 值為60printf("%d", ++(*p->y));//p->y 值為&dt[1],++20==21return 0;
}輸出:
51,60,21
2,如果結(jié)構(gòu)變量s中的生日是“1984年11月11日”,下列對(duì)其生日的正確賦值是(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;
總結(jié)
以上是生活随笔為你收集整理的PTA ---结构错题汇总的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 类型定义
- 下一篇: 给定n本书的名称和定价,本题要求编写程序