鱼C论坛

 找回密码
 立即注册
查看: 2537|回复: 3

这是一道求十位学生的平均分数的代码,怎么也不知道错在哪里了

[复制链接]
发表于 2014-8-9 17:26:24 | 显示全部楼层
  1. #include<stdio.h>
  2. void test(int * b);
  3. //void test(int b[10]);
  4. void main()
  5. {
  6.         int score[10]={2, 4, 6, 8,10,12,14,16,18,20};
  7.         test(score);
  8.        
  9. }
  10. //void score(int b[10])
  11. void test(int * b)
  12. {
  13.         int i=0,s=0;
  14.         float z;
  15.         for(;i<10;i++)
  16.         {
  17.                 s=s + b[i];
  18.                 //z=s/10;  
  19.         }   
  20.         z = s/10;
  21.         printf("%d\n",s);
  22.         printf("%f\n",z);
  23.        
  24.        
  25. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-9-24 06:22

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表