TOP

计算机二级考试C语言试题11
2011-09-20 13:20:46 来源: 作者: 【 】 浏览:292次 评论:0
微信搜索关注"91考试网"公众号,领30元,获取公务员、事业编、教师等考试资料40G!

13有一个一维数组score,内放10个学生成绩,求平均成绩。

 

#include <stdio.h>

 

void main()

 

float  averagefloat array10]);  /* 函数声明 */

 

     float score[10] , aver

 

  int i;

 

  printf(″input 10 scores:\n″);

 

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

 

     scanf(″%f″,&score[i]);

 

  printf(″\n″);

 

  averaverage score );

 

  printf (″ average score is %5.2f\n, aver);

 

 

float  average float  array10])

 

int  i

 

  float  aversumarray[ 0 ]

 

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

 

 sumsum array[ i ]

 

 aversum10

 

 returnaver);

 

 

 

运行情况如下:

 

input 10 scores100 56 78 98.5 76 87 99 67.5 75 97

 

average score is 83.40

 

14编写一个函数,用来分别求数组score_1和数组score_2各元素的平均值。

 

#include <stdio.h>

 

void  main()

 

  float   averagefloat  array ],int n)

 

      float  score_1[5] {98.5, 97, 91.5, 60, 55}

 

      float score_210={ 67.589.59969.5

 

                                7789.576.5546099.5};

 

  printf(“the average of class A is %6.2fn”

 

                   average(score_15) );

 

     printf(“the average of class B is %6.2fn”

 

                   average(score_210) );

 

 

 

float   averagefloat  array int n)

 

  int i

 

   float  aversum=array[0]

 

   fori=1i<ni + +)

 

       sumsumarray[i]                  运行结果:the average of class A is 80.40

 

  aversum / n                                  The average of class B is  78.20

 

 return(aver)

 

 

15有一个3×4的二维数组,设计一个函数,用来求二维数组中所有元素中的最大值。

 

#include <stdio.h>

 

void  main()

 

max_value ( int  arrary[ ] [4])

 

   int [3][4]={{1,3,5,7},{2,4,6,8},{15,17,34,12}}

 

   printf(″max value is %d\n″,

 

                    max_value(a) );

 

 

 

max_value   int array[ ][4]

 

  int  ijmax

 

    max=array[0][0]

 

  fori=0i< 3i + +

 

      forj=0j<4j++)                      运行结果:max value is 34

 

   ifarray[ i ][ j ]> max

 

                    max= array [ i ][ j ]

 

     returnmax);

 

  

 

Tags: 责任编辑:91kaoshiwang
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇计算机二级考试C语言试题12 下一篇计算机二级考试C 语言试题10

相关栏目

最新文章

推荐文章

网站客服QQ: 960335752 - 14613519 - 48225117