- 1、本文档共5页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
2015 年研究生入学考试复试笔试
C 语言程序设计
第一题、填空题第二题、改错题
考点:宏定义的语法标准
考点:作连乘运算时,初始化话变量 result=1不,为 0
考点:for循环语句的语法标准 (括号内用分号分割,而不是逗号)
考点:文件的打开与关闭函数
考点:输出语句printf中占位符的用法
第三题、读程序写结果
# include stdio.h void main()
{
long fun(int n); Printf(“%ld\n”,fun(4));
}
long fun(int n)
{
long s;
If(h==1 || h==2) s=2; else
s=h+fun(h-1); return (s);
}
# include stdio.h int run(int a,int b)
{
return (a+b);
}
void main()
{
int x=2,y=5,z=8,r;
r = run(run(x,y),z);
Printf(“%d \n”,r);
}
# include stdio.h void main()
{
int x[]={0,1,2,3,4,5… 9};
int s=0,I,*p=x; for(i=1;i10;i+=2) s+=*(p+i);
Printf(“s=%d\n”,s);
}
# include stdio.h int x=12,y=7;
void main()
{
int x=15,z; z=x-y++;
{
int y,z; while(y=x--)
{
y/=3; if(y%3==0)
{
z=(++y);
break;
}
}
Printf(“%d,%d,%d”,x,y,z);
}
Printf(“%d,%d,%d\n”,x,y,z);
}
第四题、读程序或函数写功能
’\的0’含义是什么?第二个 for语句的功能是什么? void fun(char a[],char x)
{
int i,j; for(i=0;a[i]!=’\0’;i++){
if(a[i]==x)
{
for(j=i;a[j]!=’\0’,j++) a[i]=a[i+1];
i--;
}
}
}
下面的函数中,p++的含义是什么?函数 f的功能是什么? int f(char *s)
{
char *p=s; while(*p) p++; return(p-s);
}
第五题、程序设计题
求 num 各位数字之和#includestdio.h
void main()
{
int n, s=0 ;
printf 您(输入的整数是:\n ); scanf(%d,n);
do
{
s=s+n%10; n/=10;
}while(n!=0);
printf 这(个数的各位数字之和为:%d , s );
}
测试字符C 在字符串S 中出现的次数#includestdio.h
void main()
{
char st[20],c; int count=0;
printf 输(入一串字符:\n ); gets(st);
printf 输(入你要测试的字符:\n ); scanf(%c,c);
for(int i=0;st[i]!=\0;i++)
{
if(st[i]==c)
count++;
}
printf 字(符%c 在%s 中出现的次数为%d\n ,c,st,count);
}
中国有句俗语叫“三天打鱼两天晒网”。某人从1990 年 1 月 1 日起开始“三天打鱼两天晒网”,问这个人在以后的某一天中是打鱼还是晒网
2015 第二批复试 C 语言笔试
第五题、程序设计题
编写自定义程序段,实现在字符串Str1的 r位置插入字符串str2 #includestring.h
#includestdio.h
void sort(char str1[],char str2[],int n)
{
int i,j;
int l = strlen(str1); int k = strlen(str2);
for (i = l; i=(n-1); i--)
{
str1[i+k]=str1[i];
}
for (j=0; jk; j++)
{
str1[i+1]=str2[j]; i++;
}
puts(str1);
}
void main()
{
int n;
char st1[100],st2[50]; printf 输(入一串字符\n ); gets(st1);
printf 输(入要插入的字符串\n ); gets(st2);
printf 要(在第几个字符插入\n ); scanf(%d,n);
sort(st1,st2, n);
}
输入数值个数n,输入正整数,用程序实现输入每个正整数数位数字之和存放
文档评论(0)