有以下程序structSTU{charname[10];intnum;};voidf1(structSTUC){structSTUb={“LiSiGuo”,2042};C=b;}voidf2(structSTU*C){structSTUb={“SunDan”,2044};*C=b;}main(){structSTUa={“YangSan”,2041},b={“WangYin”,2043};f1(a);f2(&b);printf(“%d%d\n”,a.num,b.num);}执行后的输出结果是()
A. 20412044
B. 20412043
C. 20422044
D. 20422043
查看答案
有以下程序structSTU{charname[10];intnum;intScore;};main(){structSTUs[5]={{“YangSan”,20041,703},{“LiSiGuo”,20042,580},{“wangYin”,20043,680},{“SunDan”,20044,550},{“Penghua”,20045,537}},*p[5],*t;inti,j;for(i=0;i<5;i++)p[i]=&s[i];for(i=0;i<4;i++)for(j=i+1;j<5;j++)if(p[i]->Score>p[j]->Score){t=p[i];p[i]=p[j];p[j]=t;}printf(“5d%d\n”,s[1].Score,p[1]->Score);}执行后输出结果是()
A. 550550
B. 680680
C. 580550
D. 580680
有以下程序#includestructNODE{intnum;structNODE*next;};main(){structNODE*p,*q,*r;intsum=0;p=(structNODE*)malloc(sizeof(structNODE));q=(structNODE*)malloc(sizeof(structNODE));r=(structNODE*)malloc(sizeof(structNODE));p->num=1;q->num=2;r->num=3;p->next=q;q->next=r;r->next=NULL;sum+=q->next->num;sum+=p->num;printf(“%d\n”,sum);}执行后的输出结果是()
A. 3
B. 4
C. 5
D. 6
有以下程序(提示:程序中fseek(fp,-2L*sizeof(int),SEEK_END);语句的作用是使位置指针从文件尾向前移2*sizeof(int)字节)#includemain(){FILE*fp;inti,a[4]={1,2,3,4},b;fp=fopen("data.dat","wb");for(i=0;i<4;i++)fwrite(&a,sizeof(int),1,fp);fclose(fp);fp=fopen("data.dat","rb");fseek(fp,-2*sizeof(int),SEEK_END);fread(&b,sizeof(int),1,fp);/*从文件中读取sizeof(int)字节的数据到变量b中*/fclose(fp);printf("%d\n",b);}执行后输出结果是()
A. 2
B. 1
C. 4
D. 3
下面的程序执行后,文件test中的内容是()#includevoidfun(char*fname,char*st){FILE*myf;inti;myf=fopen(fname,“w”);for(i=0;st[i]!=’\0’;i++)fputc(st[i],myf);fclose(myf);}main(){fun(“test”,“newworld”);fun(“test”,“hello,”);}
A. hello,
B. newworldhello,
C. newworld
D. hello,newworld