- 15
- 0
- 约4.27千字
- 约 5页
- 2018-12-01 发布于浙江
- 举报
C语言模拟试卷10
C语言模拟试卷18
阅读以下程序,写出程序运行结果(每题4分共40分)。
1、main()
{
int x,y,t;
printf(input x and y:);
scanf(%d,%d,x,y);
if (xy)
{
t=x;
x=y;
y=t;
}
printf(%d,%d\n,x,y);
}
当输入4,8回车
输出结果是:
2、#includestdio.h
main()
{
char ch;
while((ch=getchar())!=\n)
{
if (ch=Ach=Z)
ch=ch+32;
else if((ch=ach=z))
ch=ch-32;
printf(%c,ch);
}
printf(\n);
}
设输入:236BCdef回车
输出结果是:
3、#includestdio.h
main()
{
int i, j=3, a[ ]={1,2,3,4,5,6,7,8,9,10};
for (i=0; i5; i++) a[i]=i*(i+1);
for (i=0; i4; i++) j+=a[i]*3;
printf(%d,j);
}
输出结果是:
4、#includestdio.h
int abc(int u,int v);
main()
{
int a=24,b=16,c;
c=abc(a,b);
printf(%d\n,c);
}
int abc(int u,int v)
{
int w;
while(v)
{ w=u%v;u=v;v=w;}
return u;
}
输出结果是:
5、#includestdio.h
long fib(int n)
{ if(n==0)
return (0);
else if(n==1)
return (1);
else
return(fib(n-2)+fib(n-1));
}
main()
{
printf(%d\n,fib(6));
}
输出结果是:
6、#includestdio.h
struct two
{ int n;
char ch;
};
func(struct two ex2);
main()
{
struct two ex1={5,t};
func(ex1);
printf(%d,%c,ex1.n,ex1.ch);
}
func(struct two ex2)
{
ex2.n+=10;
ex2.ch-=1;
}
运行结果:
7、#includestdio.h
main()
{
int a[ ]={ 9,8,7,6,5,4,3,2,1,0}, *p=a;
printf(%d,*p+7);
}
运行结果:
8、#includestdio.h
void f(int a, int b, int *c, int *d)
{ a=30; b=40;
*c=a+b; *d=*d-a;
}
main()
{ int a=10,b=20,c=30,d=40;
f(a,b,c,d);
printf(%d,%d,%d,%d\n,a,b,c,d);
}
运行结果:
9、main()
{ char s[12]=abcde;
scanf(%s,s);
strcat(s,fgh);
printf(%s\n,s);
}
运行结果:
10、#include stdio.h
main( )
{ char *p=I am a srudent.;
p=p+3;
printf(%s,p);
}
运行结果:
二、改错题(每空1分共10分)
1、#includestdio.h
main
{
int account;
char name[30];
FILE cf;
您可能关注的文档
最近下载
- 管理会计(第三版)冯巧根-第9章 责任会计(2017版).ppt VIP
- GB150考试试题.doc VIP
- 大学(毕业论文)范文.doc VIP
- 《经济学基础》高职全套教学课件.pptx
- 2026年度中国建设银行远程智能银行中心社会招聘客服代表180人参考考试试题附答案解析.docx VIP
- 深度解析(2026)《YBT 5115-2025铝硅质耐火可塑料》.pptx VIP
- 2026年苏州工艺美术职业技术学院单招职业适应性测试备考题库及答案解析.docx VIP
- 2026中国建设银行远程智能银行中心客服代表社会招聘200人笔试备考试题附答案解析.docx VIP
- 煤矿井下电气整定计算说明.pdf VIP
- LEGO乐高积木拼砌说明书71423,与枯骨酷霸的城堡对战,LEGO®SuperMario™(年份2023)安装指南_共2份(全).pdf
原创力文档

文档评论(0)