-
1以下程序段中,不能正确赋字符串(编译时系统会提示错误)的是( )
A.char s[10]=”abcdefg”;
B.char t[]=”abcdefg”,*s=t;
C.char s[10];s=”abcdefg”;
D.char s[10];strcpy(s,”abcdefg”);
开始考试点击查看答案 -
2有以下程序void sort(int a[],int n){ int i,j,t; for(i=0;i<n-1;i+=2) for(j=i+2;j<n;j+=2) if(a[i]<a[j]) { t=a[i];a[i]=a[j];a[j]=t;}}main(){ int aa[10]={1,2,3,4,5,6,7,8,9,10},i; sort(aa,10); for(i=0;i<10;i++) printf(“%d”,aa[i]); printf(“n”);} 其输出结果是( )
A.1,2,3,4,5,6,7,8,9,10,
B.10,9,8,7,6,5,4,3,2,1,
C.9,2,7,4,5,6,3,8,1,10,
D.1,10,3,8,5,6,7,4,9,2,
开始考试点击查看答案 -
3下面程序的功能是输出以下形式的金字塔图案是:****************main( ){ int i,j; for(i=1;i<=4;i++) { for(j=1;j<=4-i;j++) printf(“ “); for(j=1;j<=_____;j++) printf(“*”); printf(“n”); }} 在下划线处应填入的是( )
A.i
B.2*i-1
C.2*i+1
D.i+2
开始考试点击查看答案 -
4有以下程序main( ){ unsigned char a,b; a=4|3; b=4&3; printf(“%d %dn”,a,b);} 执行后输出结果是( )
A.7 0
B.0 7
C.1 1
D.43 0
开始考试点击查看答案 -
5有以下程序struc 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 %dn”,
A.num,
B.num);} 执行后的输出结果是( )A.2041 2044B.2041 2043
C.2042 2044
D.2042 2043
开始考试点击查看答案 -
6有以下程序void f(int a[],int i,int j){ int t; if(i<j) { t=a[i]; a[i]=a[j];a[j]=t; f(a,i+1,j-1); }}main( ){ int i,aa[5]={1,2,3,4,5}; f(aa,0,4); for(i=0;i<5;i++) printf(“%d,”,aa[i]); printf(“n”);} 执行后输出结果是( )
A.5,4,3,2,1,
B.5,2,3,4,1,
C.1,2,3,4,5,
D.1,2,3,4,5,
开始考试点击查看答案 -
7有以下程序struct STU{ char name[10]; int num; int Score;};main( ){ struct STU s[5]={{“YangSan”,20041,703}, {“LiSiGuo”,20042,580}, {“wangYin”,20043,680}, {“SunDan”,20044,550}, {“Penghua”,20045,537}},*p[5],*t; int i,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 %dn”,s[1].Score,p[1]->Score);} 执行后输出结果是( )
A.550 550
B.680 680
C.580 550
D.580 680
开始考试点击查看答案 -
8有以下程序#include <stdlib.h>struct NODE{ int num; struct NODE *next; };main( ){ struct NODE *p,*q,*r; int sum=0; p=(struct NODE *)malloc(sizeof(struct NODE)); q=(struct NODE *)malloc(sizeof(struct NODE)); r=(struct NODE *)malloc(sizeof(struct NODE)); 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(“%dn”,sum);} 执行后的输出结果是
A.3
B.4
C.5
D.6
开始考试点击查看答案 -
9有以下程序#include <stdio.h>main( ){ FILE *fp; int i,k=0,n=0; fp=fopen(“d1.dat”,”w”); for(i=1;i<4;i++) fprintf(fp,”%d”,i); fclose(fp); fp=fopen(“d1.dat”,”r”); fscanf(fp,”%d%d”,&k,&n); printf(“%d %dn”,k,n); fclose(fp);} 执行后输出结果是( )
A.1 2
B.123 0
C.1 23
D.0 0
开始考试点击查看答案 -
10有以下程序(提示:程序中fseek(fp,-2L*sizeof(int),SEEK_END);句的作用是使位置指针从文件尾向前移2*sizeof(int)字节)#include <stdio.h>main( ){ FILE *fp; int i,a[4]={1,2,3,4},b; fp=fopen("dat
A.dat","wb"); for(i=0;i<4;i++) fwrite(&a[i],sizeof(int),1,fp); fclose(fp); fp=fopen("data.dat","rb"); fseek(fp,-2L*sizeof(int).SEEK_END); fread(&b,sizeof(int),1,fp);/*从文件中读取sizeof(int)字节的数据到变量b中*/ fclose(fp); printf("%dn",b);} 执行后输出结果是( )A.2
B.1
C.4
D.3
开始考试点击查看答案