C语言第21套题,2012全国计算机二级C语言(C++)题库 第21套题

微信搜索关注"91考试网"公众号,领30元,获取公务员、事业编、教师等考试资料40G!

第21套题

一、程序填空题

#include 

int fun(int  x)

{ int  n, s1, s2, s3, t;

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

n=__1__;

t=100;

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

while(t<=__2__)

{ s1=t%10;  s2=(t/10)%10;  s3=t/100;

if(s1+s2+s3==15)

{  printf("%d ",t);

n++;

}

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

__3__;

}

return n;

}

main()

{ int  x=-1;

while(x>999||x<0)

{  printf("Please input(0

printf("\nThe result is: %d\n",fun(x));

}

二、程序改错题

#include

#include

void fun (char  *s, char  *t)

{

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

int   i;

sl = strlen(s);

for (i=0; i

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

t[i] = s[sl-i];

for (i=0; i

t[sl+i] = s[i];

t[2*sl] = '\0';

}

main()

{  char s[100], t[100];

printf("\nPlease enter string s:"); scanf("%s", s);

fun(s, t);

printf("The result is: %s\n", t);

}

三、程序编写题

#include

void fun(int a, int b, long *c)

{

}

main()   /* 主函数 */

{  int a,b; long c;void NONO ();

printf("Input a b:");

scanf("%d%d", &a, &b);

fun(a, b, &c);

printf("The result is: %ld\n", c);

NONO();

}

void NONO ()

{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */

FILE *rf, *wf ;

int i, a,b ; long c ;

rf = fopen("K:\\k01\\24010001\\in.dat","r") ;

wf = fopen("K:\\k01\\24010001\\out.dat","w") ;

for(i = 0 ; i < 10 ; i++) {

fscanf(rf, "%d,%d", &a, &b) ;

fun(a, b, &c) ;

fprintf(wf, "a=%d,b=%d,c=%ld\n", a, b, c) ;

}

fclose(rf) ;

fclose(wf) ;

}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值