首页 > 职业资格考试
题目内容 (请给出正确答案)
[单选题]

有以下程序:struct s{ int x,y; }data[2]={10,100,20,200};main(){ struct s *p=data;printf("%d\n",(p)->x);}程序运行后的输出结果是()。

A.10

B.11

C.20

D.21

答案
收藏

C、20

解析:结构体;struct s *p=data; 使p指向data的首地址,而++p->x,先使p指向下一位即20,然后输出其值。

如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“有以下程序:struct s{ int x,y; }data…”相关的问题
第1题
有以下程序 structSTU {charnum[10];floatscore[3];}; main() {structSTUs[3]={{"20021

有以下程序

struct STU

{ char num[10]; float score[3]; };

main()

{struct STU s[3]={{"20021",90,95,85},

{"20022",95,80,75},

{ "20023",100,95,90},

},*p=s;

int i; float sum=0;

for(i=0;i<3;i++)

sum=sum+p->score[i];

printf("%6.2f\n",sum);

}

程序运行后的输出结果是

A.260.00

B.270.00

C.280.00

D.285.00

点击查看答案
第2题
有以下说明语句struct s{int a;char b;float f;}s1;则语句printf("%d",sizeof(s1))()

A.2

B.3

C.7

D.6

点击查看答案
第3题
有以下程序 #include<stdlib.h> struct NODE {int num;struct NODE*next;} main() {struct NODE

有以下程序

#include<stdlib.h>

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(struet 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):

}

程序运行后的输出结果是()

A.10

B.20

C.30

D.40

点击查看答案
第4题
有以下程序:struct STU{char name[10];int num;}; void f1(struct STU c){ struct STU b={"LiSiG

有以下程序: struct STU{ char name[10]; int num; }; void f1(struct STU c) { struct STU b={"LiSiGuo",2042); c=b; } void f2(struct STU *c) { struct STU b={"SunDan",2044); *c=b; } main() {struct STU a={"YangSan",2041},b={"WangYin",2043); f1(a);f2(&b); printf("%d %d\n",a.num,b.num); } 执行后输出结果是()。

A.2041 2044

B.2041 2043

C.2042 2044

D.2042 2043

点击查看答案
第5题
阅读以下说明和C语言程序,将应填入(n)处的字句写在对应栏内。 【说明】 以字符流形式读入一个文件,

阅读以下说明和C语言程序,将应填入(n)处的字句写在对应栏内。

【说明】

以字符流形式读入一个文件,从文件中检索出6种C语言的关键字,并统计、输出每种关键字在文件中出现的次数。本程序中规定:单词是一个以空格或'\t'、'\n'结束的字符串。其中6种关键字在程序中已经给出。

【程序】

include <stdio.h>

include <stdlib.h>

FILE *cp;

char fname[20], buf[100];

int NUM;

struct key

{ char word[10];

int count;

}keyword[]={ "if", 0, "char", 0, "int", 0,

"else", 0, "while", 0, "return", 0};

char *getword (FILE *fp)

{ int i=0;

char c;

while((c=getc(fp))!= EOF &&(1));

if(c==EOF)

return (NULL);

else

buf[i++]=c;

while((c=fgetc(fp))!=EOF && c!="&& c!='\t' && c!='\n' )

buf[i++]=c;

buf[i]='\0';

return(buf);

}

void lookup(char *p)

{ int i;

char *q, *s;

for(i=0; i<NUM; i++)

{ q=(2);

s=p;

while(*s && (*s==*q))

{ (3))

if((4))

{ keyword[i].count++;

break;

}

}

return;

}

void main()

{ int i;

char *word;

printf("lnput file name:");

scanf("%s", fname);

if((cp=fopen(fname, "r"))==NULL)

{ printf("File open error: %s\n", fname);

exit(0);

}

NUM=sizeof(keyword)/sizeof(struct key);

while((5))

lookup(word);

fclose(cp);

for(i=0;i<NUM;i++)

printf("keyword:%-20s count=%d\n",keyword[i].word,keyword[i].count);

}

点击查看答案
第6题
若有以下语句: typedef struct S {int g;char h;}T; 以下叙述中正确的是()。 A.可用S定义结构

若有以下语句: typedef struct S {int g;char h;}T; 以下叙述中正确的是()。

A.可用S定义结构体变量

B.可用T定义结构体变量

C.S是struct类型的变量

D.T是struct S类型的变量

点击查看答案
第7题
以下程序的运行结果是______。 struct Node} int x; char ch; }; f
un(struct Node*sn) } static k=1; sn->x=20; Sn->ch=a+k++; } main() { int i; static struct Node st=}10,a}; for(i=0;i<2;i++) fun(&st); printf("%d,%c\n",st.x,st.ch); }

点击查看答案
第8题
以下程序输出结果是( )。 struct stu {int x; int *y; }*p; int dt[4]={10,20,30,40}; struct stu a[4]=150,&dt[0],60,&dt[1],70,&dt[2],80,&dt[3]}; main() { p=a; printf("%d,",++p->x); //语句1 printf("%d,",(p)->x); //语句2 printf("%d\n",++(*p->y)); //语句3 }

A.10,20,20

B.50,60,21

C.51,60,21

D.60,70,31

点击查看答案
第9题
有以下程序#include<stdio.h>int fun(){static int x=l:X*=2:return X:}main(){int i,s=l:for(i=l;i<=3,i++) s*=fun();printf(“%d\n”,s);}程序运行后的输出结果是

A.0

B.10

C.30

D.64

点击查看答案
第10题
有以下程序:#include <stdio.h>main(){int i,s=0,t[] = {1,2,3,4,5,6,7,8,9};for(i=0;i<9;i+=2)

有以下程序:#include <stdio.h>main(){ int i,s=0,t[] = {1,2,3,4,5,6,7,8,9}; for(i=0;i<9;i+=2) s+=*(t+i); prinff("% d \n ",s);

A.45

B.20

C.25

D.36

点击查看答案
第11题
有以下程序#include<stdio.h>#define S(x)4*(x)*x+1main(){int k=5,j=2; printf(“%d\n”,S(

有以下程序

#include<stdio.h>

#define S(x)4*(x)*x+1

main()

{int k=5,j=2;

printf(“%d\n”,S(k+j));

}

程序运行后的输出结果是

A.197

B.143

C.33

D.28

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改