2010年c语言上机题库,2010年计算机c语言上机题库.doc

2010年计算机c语言上机题库

2010年计算机c语言上机题库

校园网·新视野教育二级C上机考试复习资料 V16.0

(共50套题目)

第1套 校园网·新视野教育上机考试复习资料

1、程序填空题

#include

#include

double fun(double x)

{ double f, t; int n;

f = 1.0 + x;

/**********found**********/

t = ___y___;

n = 1;

do {

n++;

/**********found**********/

t *= (-1.0)*x/___n_;

f += t;

}

/**********found**********/

while (___fabs(t)___ >= 1e-6);

return f;

}

main()

{ double x, y;

x=2.5;

y = fun(x);

printf("\nThe result is :\n");

printf("x=%-12.6f y=%-12.6f\n", x, y);

}

2、程序修改题 校园网·新视野教育上机考试复习资料

#include

long fun(int x,int y,long *p )

{ int i;

long t=1;

/**************found**************/

for(i=1; i<=y; i++)

t=t*x;

*p=t;

/**************found**************/

t=t%1000;

return t;

}

main()

{ long t,r; int x,y;

printf("\nInput x and y: "); scanf("%ld%ld",&x,&y);

t=fun(x,y,&r);

printf("\n\nx=%d, y=%d, r=%ld, last=%ld\n\n",x, y,r,t );

}

3、程序设计题 校园网·新视野教育上机考试复习资料

#include

#include

double fun(double x)

{

int i=0;

double s=1,a=1;

while(fabs(a)>0.000001)

{

a=a*(0.5-i)*x/(i+1);

s+=a;

i++;

}

return s;

}

main()

{ double x,s;

printf("Input x: "); scanf("%lf",&x);

s=fun(x);

printf("s=%f\n",s);

}

第2套 校园网·新视野教育上机考试复习资料

1、程序填空题

#include

int c1,c2,c3;

void fun(long n)

{ c1 = c2 = c3 = 0;

while (n) {

/**********found**********/

switch(___n/10___)

{

/**********found**********/

case 1: c1++;___break___;

/**********found**********/

case 2: c2++;___break___;

case 3: c3++;

}

n /= 10;

}

}

main()

{ long n=123114350L;

fun(n);

printf("\nThe result :\n");

printf("n=%ld c1=%d c2=%d c3=%d\n",n,c1,c2,c3);

}

2、程序修改题 校园网·新视野教育上机考试复习资料

#include

int fun(unsigned n, int *zero)

{ int count=0,max=0,t;

do

{ t=n%10;

/**************found**************/

if(t==0)

count++;

if(max

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值