浙江省秋季C语言二级考试上机编程试题及答案_精品文档Word格式文档下载.doc
- 文档编号:13152039
- 上传时间:2022-10-06
- 格式:DOC
- 页数:29
- 大小:2.11MB
浙江省秋季C语言二级考试上机编程试题及答案_精品文档Word格式文档下载.doc
《浙江省秋季C语言二级考试上机编程试题及答案_精品文档Word格式文档下载.doc》由会员分享,可在线阅读,更多相关《浙江省秋季C语言二级考试上机编程试题及答案_精品文档Word格式文档下载.doc(29页珍藏版)》请在冰豆网上搜索。
printf("
%d,%d,%d"
a,b,c);
2.表达式求和。
#include<
math.h>
{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.141594
3.字母后移循环输出。
{charc;
c=getchar();
if(______1______)//c>
='
a'
&
&
c<
'
v'
c=c+5;
else
if(c>
z'
)
______2______//c=c-21;
putchar(c);
}
4.求满足条件的数。
{floaty=1.05;
intn=1;
FILE*p;
//以下开始做答
while(!
(pow(y,n)<
1e6&
pow(y,n+1)>
1e6))
n++;
p=fopen("
Design2.dat"
fprintf(p,"
%d,%.0f"
n,pow(1.05,n));
fclose(p);
283,992137
5.求满足条件的数。
{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\n"
m);
6.求平面点间的最短距离。
#definelen(x1,y1,x2,y2)sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
{FILE*p;
inti,j;
floatc,minc;
floatx[]={1.1,3.2,-2.5,5.67,3.42,-4.5,2.54,5.6,0.97,4.65};
floaty[]={-6,4.3,4.5,3.67,2.42,2.54,5.6,-0.97,4.65,-3.33};
minc=len(x[0],y[0],x[1],y[1]);
p=fopen("
for(i=0;
i<
9;
i++)
for(j=i+1;
j<
10;
j++)
if((c=len(x[i],y[i],x[j],y[j]))<
minc)
minc=c;
fprintf(p,"
%f"
minc);
fclose(p);
1.457944
7.Fibonacci数列求值问题。
_______1______//longf(intn);
{printf("
%ld\n"
f(30));
longf(intn)
{if(______2______)//n==1||n==2
return1;
returnf(n-1)+f(n-2);
832040
8.多项式求和问题。
floatx=1.279,t=1,y=0;
floata[10]={1.1,3.2,-2.5,5.67,3.42,-4.5,2.54,5.6,0.97,4.65};
y=a[0];
for(i=1;
{t=t*x;
y=y+t*a[i];
y);
98.722542
9.整数转换为字符串。
#include<
voiditoa(longi,char*s)
{if(i==0)return;
/******1******/
*s='
1'
+i%10;
//*s='
0'
+i%10
itoa(i/10,s-1);
{longn;
charstr[7]="
"
;
scanf("
%ld"
n);
/******2******/
itoa(n,str+6);
// itoa(n,str+5);
%s"
str);
10.Fibonacci数列求值问题。
{FILE*p;
inti;
floatf1=1.0,f2=2.0,t1=2.0,t2=3.0,s;
floatf,t;
s=t1/f1+t2/f2;
for(i=3;
40;
i=i+2)
{t1=t1+t2;
t2=t1+t2;
f1=f1+f2;
f2=f1+f2;
s=s+t1/f1+t2/f2;
fprintf(p,"
s);
65.020950
11.数组赋值。
{inta[10],b[10],i;
\ninput10numbers:
"
for(i=0;
i<
i++)/*数组输入*/
scanf("
&
a[i]);
for(i=1;
i++)
b[i]=______1______;
//b[i]=a[i]+a[i-1];
{printf("
%3d"
b[i]);
if(______2______)printf("
\n"
//i%3==0}}
12.求各点距离和。
#include<
inti;
floatx[10]={-1.5,2.1,6.3,3.2,-0.7,7.0,5.1,3.2,4.5,7.6};
floaty[10]={3.5,7.6,8.1,4.5,6.0,1.1,1.2,2.1,3.3,4.4};
floats=0.0;
s=s+sqrt(pow(x[i]-1,2)+pow(y[i]-1,2));
fclose(p);
52.679447
13.十进制数转换为二进制数。
voiddec2bin(intm)
{intbin[32],j;
for(j=0;
m!
=0;
{bin[j]=______1______;
//m%2
m=m/2;
}
for(;
j!
j--)
printf("
______2______);
//bin[j-1]}
{intn;
dec2bin(n);
}
14.求符合条件的数列之和。
floats=0,a=81;
inti;
p=fopen("
=30;
{s=s+a;
a=sqrt(a);
%.3f"
121.336
15.在字符串中删除数字字符。
string.h>
ctype.h>
voidf(char*s)
{inti=0;
while(s[i]!
\0'
){
if(isdigit(s[i]))____1____(s+i,s+i+1);
//strcpy
___2___i++;
}//else}
{charstr[80];
gets(str);
f(str);
puts(str);
16.求满足条件的数。
floatf(float
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 浙江省 秋季 语言 二级 考试 上机 编程 试题 答案 精品 文档