云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 计算机二级C语言上机题库及答案(100套)

计算机二级C语言上机题库及答案(100套)

  • 62 次阅读
  • 3 次下载
  • 2025/4/30 16:14:02

{

for(j=0;j<3;j++)

printf(\ printf(\ }

fun(array); printf(\ out = fopen(\ for (i=0;i<3;i++) {

for(j=0;j<3;j++) {

printf(\ fprintf(out, \ }

printf(\ fprintf(out, \ }

fclose(out); } 答案是:

void fun(int array[3][3]) {

int i,j,temp; for(i=0;i<3;i++) for( j=0;j

{

temp=array[i][ j]; array[i][ j]=array[ j][i]; array[ j][i]=temp;

} }

第 19 套

填空题

给定程序的功能是计算 SCORE 中 M 个人的平均成绩 AVER,将 低于 AVER 的成绩放在 BELOW 中,通过函数名返回人数。 例如,当 SCORE={10,20,30,40,50,60,70,80,90}, M=9 时,函数返回人数应该是 4,BELOW={10,20,30,40}。 注意:部分源程序给出如下

请勿改动主函数 main 和其他函数中的任何内容,仅在

横线上填入所编写的若干表达式或语句。 试题程序:#include

#include

int fun(int score[], int m, int below[]) {

int i, j = 0; float aver = 0.0; for (i=0; i

if (score[i] < aver) below[j++] =

1 ;

return j; } main() {

int i, n, below[9];

int score[9] = {10, 20, 30, 40, 50, 60, 70, 80, 90}; n = fun(score, 9, for (i=0; i

2 ); printf(\ printf(\}

第 1 处填空:score[i]或*(score+i) 第 2 处填空:below

第 3 处填空:below[i]或*(below+i)

3 );

改错题

下列给定程序中函数 FUN 的功能是:从低位开始取出长整型变 量 S 中偶数位上的数依次构成一个新数放在 T 中。例如,当 S 中的数为 时,T 中的数为 642。

请改正程序中的错误,使它能得出正确结果。

注意:不要改动 MAIN 函数,不得增行或删行,也不要更改程 序的结构!

试题程序:#include

#include /********found********/ void fun(long s, long t) {

long s1 = 10; s /= 10; *t = s;

/********found********/ while (s < 0) {

s = s/100; *t = s*s1+*t; s1 = s1*10; }

} main() {

long s, t; printf(\enter s:\ scanf(\ fun(s, &t);

printf(\ }

第 1 处:void fun(long s,long t) 应改为 void fun(long s,long *t)

第 2 处:while(s<0)应改为 while(s>0)

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

{ for(j=0;j<3;j++) printf(\ printf(\ } fun(array); printf(\ out = fopen(\ for (i=0;i<3;i++) { for(j=0;j<3;j++) { printf(\ fprintf(out, \ } printf(\ fprintf(out, \ } fclose(out); } 答案是: void fun(int array[3][3]) { int i,j,temp; for(i=0;i<3;i++) for( j=0;j

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com