资源描述:
《浙江省秋季C语言二级考试上机编程试题及答案.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、浙江省2011年秋季C语言二级考试上机编程试题及答案1.三个数比较大小。#includevoids)//int*pa,int*pb{/*交换两个数的位置*/inttemp;temp=*pa;*pa=*pb;*pb=temp;}voidmain(){inta,b,c,temp;scanf("%d%d%d",&a,&b,&c);if(a>b)s);if(b>c)s);if(______2______)//a>bs);printf("%d,%d,%d",a,b,c);}2.表达式求和。#include
2、#includevoidmain(){FILE*fp;floatn=1,t=1,pi=0;inti;//从以下开始答题i=1;while(fabs(t)>=1e-6){pi=pi+t;i=-i;n=n+2;t=i/n;}fp=fopen("Design1.dat","w");fprintf(fp,"%.6f",4*pi);fclose(fp);}运行结果:3.1415943.字母后移循环输出。#includevoidmain(){charc;c=getchar(
3、);if(______1______)//c>='a'&&c<'v'c=c+5;elseif(c>='v'&&c<='z')______2______//c=c-21;putchar(c);}4.求满足条件的数。#include#includevoidmain(){floaty=1.05;intn=1;FILE*p;//以下开始做答while(!(pow(y,n)<1e6&&pow(y,n+1)>1e6))n++;p=fopen("Design2.dat","w");fprint
4、f(p,"%d,%.0f",n,pow(1.05,n));fclose(p);}运行结果:283,9921375.求满足条件的数。#includevoidmain(){intm=0,t=1,n;while(_____1________);//(scanf("%d",&n),n<=0)while(!(t<=n&&t*2>=n)){_____2_____//t=t*2;m++;}printf("%d",m);}6.求平面点间的最短距离。#include#include