1.有以下程序:
main()
{unsigned char a,b;
a=4|3;
b=4&3;
printf("%d%d\n",a,b);
}
执行后输出结果是()
A)70
B)07
C)11
D)430
2.下面程序的功能是输出以下形式的金字塔图案:
*
***
*****
*******
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
3.有以下程序:
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,
4.以下程序段中,不能正确赋字符串(编译时系统会提示错误)的是(
A)char s[10]="abcdefg";
B)char t[]="abcdefg",*s=t;
C)char s[10];s="abcdefg";
D)char s[10];strcpy(s,"abcdefg");
5.有以下程序:
#include<string.h>
main(int argc,char * argv[])
{int i,len=0;
for(i=1;i<argc;i+=2)len+=strlen(argv[i]);
printf("%d\n",len);
}
经编译链接后生成的可执行文件是ex.exe,若运行时输入以下带参数的命令行:
ex abcd efg h3 k44
执行后输出结果是()
A)14
B)12
C)8
D)6
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,5,4,3,2
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("%d%d\n",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("%d\n",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");