计算机二级C语言程序设计
VIP题库
有以下定义和语句struct workers{int num;char name[20];char c;struct{int day;int month;int year;} s;};struct workers w,*pw;pw=&w;能给w中year成员赋1980的语句是______。
设有定义:typedef struct data1{int x, y;} data2;typedef struct {float x, y;} data3;则以下不能作为类型名使用的是______。
设有定义:struct complex{int real,unreal;} data1={1,8},data2;则以下赋值语句错误的是______。
有如下程序#include struct pair{int first, second;};struct pair get_min_max(int* array, int len){int i;struct pair res;res.first = array[0];res.second = array[0];for (i=1; i res.second)res.second = array[i];}return res;}main(){int array[5] = {9, 1, 3, 4};struct pair min_max = get_min_max(array, 5);printf("min=%d,max=%d\n", min_max.first, min_max.second);}程序运行后的输出结果是______。
有以下程序#include struct st{ int x,y;} data[2]={1,10,2,20};main(){ struct st *p=data;printf("%d,",p->y);printf("%d\n",(++p)->x);}程序的运行结果是______。
若有定义typedef int* T; T a[10];则a的定义与下面哪个语句等价______。
有以下程序#include struct NODE{int num; struct NODE *next; }main(){struct NODE *p,*q,*r;p=(struct NODE *)malloc(sizeof(struct NODE));q=(struct NODE *)malloc(sizeof(struct NODE));r=(struct NODE *)malloc(sizeof(struct NODE));p->num=10;q->num=20;r->num=30;p->next=q;q->next=r;printf("%d\n",p->num+q->next->num);}程序运行后的输出结果是______。
有以下程序main(){ union{ unsigned int n;unsigned char c;}ul;ul.c=''A'';printf("%c\n",ul.n);}执行后输出结果是______。
有下列程序#include typedef struct{char name[9];char gender;int score[3];} STU;STU f(STU a){ STU b={"fan",''f'',{76,88}};a=b;a.score[2]=a.score[0]+a.score[1];return a;}main(){ STU c={"tang",''m'',{78,68}},d;d=f(c);printf("%s,%c,%d,%d,%d,",c.name,c.gender,c.score[0],c.score[1],c.score[2]);printf("%s,%c,%d,%d,%d\n",d.name,d.gender,d.score[0],d.score[1],d.score[2]);}执行后的输出结果是______。
假定建立了以下链表结构,指针p、q分别指向如图所示的结点,则以下可以将q所指结点从链表中删除并释放该结点的语句组是______。 ↓p ↓q┌─┬─┐ ┌─┬─┐ ┌─┬─┐head →│8 │ ┼→…→│4 │ ┼→ │ 3│ ┼→……└─┴─┘ └─┴─┘ └─┴─┘ data next
«
1
2
3
4
5
6
7
8
...
149
150
»