(41)下列程序是用来判断数组中特定元素的位置所在。如果输入如下整数:
876 675 896 101 301 401 980 431 451 777
以下是引用片段: #include #include int fun(int *s, int t, int *k) { int i; *k=0; for(i=0;i if(s[*k] return s[*k]; } main() { int a[10]={ 876,675,896,101,301,401,980,431,451,777},k; clrscr(); fun(a, 10, %26amp;k); printf("%d, %d\n ", k, a[k]); } |
则输出结果为
a)7,431
b)6
c)980
d)6,980
(42) c语言结构体类型变量在程序执行期间
a)所有成员一直驻留在内存中
b)只有一个成员驻留在内存中
c)部分成员驻留在内存中
d)没有成员驻留在内存中
(43)下面程序应能对两个整型变量的值进行交换。以下正确的说法是
以下是引用片段: main() {int a=10,b=20; printf("(1)a=%d,b=%d\n",a,b); swap(%26amp;a,%26amp;b); printf("(2)a=%d,b=%d\n",a,b); } swap(int p,int q) {int t; t=p;p=q;q=t; } |
a)该程序完全正确
b)该程序有错,只要将语句swap(%26amp;a,%26amp;b);中的参数改为a,b即可
c)该程序有错,只要将swap()函数中的形参p和q以及t均定义为指针(执行语句不变)即可BIJ[l6K60gI(2xmP( ( 贵州 学 习 网 IT认证全国计算机等级考试 )BIJ[l6K60gI(2xmP(hTTp://wWw.gZu521.cOm
d)以上说法都不对
(44)有以下程序
以下是引用片段: #include main() { char *p,*q; p=(char *)malloc(sizeof(char)*20); q=p; scanf("%s %s",p,q); printf("%s %s\n",p,q); } |
若从键盘输入:abc def<回车>,则输出结果是
a)def def
b)abc def
c)abc d
d)d d
(45)以下程序的输出结果是
以下是引用片段: int f() { static int i=0; int s=1; s+=i; i++; return s; } main() { int i,a=0; for(i=0;i<5;i++)a+=f(); printf("%d\n",a); } |
a)20
b)24
c)25
d)15
(46)已知 int a=1,b=3则a^b的值为
a)3
b)1
c)2
d)4
(47)如果需要打开一个已经存在的非空文件“demo”进行修改下面正确的选项是
a)fp=fopen("demo","r");
b)fp=fopen("demo","ab+");
c)fp=fopen("demo","w+");
d)fp=fopen("demo","r+");
(48)若要打开a盘上user子目录下名为abc.txt的文本文件进行读、写操作,下面符合此要求的函数调用是
a)fopen("a:\user\abc.txt","r")
b)fopen("a:\\user\\abc.txt","rt+")
c)fopen("a:\user\abc.txt","rb")
d)fopen("a:\user\abc.txt","w")
(49)有以下程序
以下是引用片段: #include main() { char *p="abcde\0fghjik\0 "; printf("%d\n ",strlen(p)); } |
程序运行后的输出结果是
a)12
b)15
c)6
d)5
(50) 有以下程序
以下是引用片段: #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); } |
程序运行后的输出结果是
a)10
b)20
c)30
d)40