历年二级考试真题及答案
outarr(aa);
}
(13)下列程序中的函数strcpy2()实现字符串两次复制,即将t所指字符串复制两次到s所指内存空间中,合并形成一个新字符串.例如t所指字符串为efgh,调用strcpy2后,s所指字符串为efghefgh.请填空.
#include <stdio.h>
#include <string.h>
void strcpy2(char *s,char *t)
{char *p=t;
while(*s++=*t++);
s=[15];
while([16]=*p++);
}
main()
{char str1[100]="abcd",str2[]="efgh";
strcpy2(str1,str2); printf("%s\n",str1);
}
(14)下面程序的运行结果是[17].
#include <stdio.h>
int f(int a[],int n)
{if(n>1)
return a[0]+f(a+1,n-1);
else
return a[0];
}
main()
{int aa[10]={1,2,3,4,5,6,7,8,9,10},s;
s=f(aa+2,4); printf("%d\n",s);
}
(15)下面程序由两个源程序文件:t4.h和t4.c组成,程序编译运行结果是[18]. t4.h的源程序为:
#define N 10
#define f2(x) (x*N)
t4.c的源程序为:
#include <stdio.h>
#define M 8
#define f(x) ((x)*M)
#include "t4.h"
main()
{int i,j;
i=f(1+1); j=f2(1+1);
printf("%d%d\n",i,j);
}
(16) 下面程序的功能是建立一个有3个结点的单循环链表,然后求各个结点数值域data中数据的和,请填空。
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库2006年9月全国计算机等级考试二级C语言笔试试题及答案(10)在线全文阅读。
相关推荐: