例8.12.txt

来自「C语言课件,清华大学出版的书的配套的.很好用,尽管下载.」· 文本 代码 · 共 20 行

TXT
20
字号
  例8.12

float average(float array[ ]
,int n)
  {int i;
   float aver,sum=array[0];
   for(i=1;i<n;i++)
     sum=sum+array[i];
   aver=sum/n;
   return(aver);
    main()
  {float score-1[5]={98.5,97,91.5,60,55};
      float score-2[10]={67.5,89.5,99,69.5,77,89.5,76.5,54,60,99.5};
    printf("the average of class A is %6.2f\n",average(score-1,5));
printf("the average of class B is %6.2f\n",average(score-2,10));
  }
  运行结果如下:
the average of class A is 80.40
  the average of class B is 78.20

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?