| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 893 人关注过本帖
标题:新手,关于for循环有些不理解
取消只看楼主 加入收藏
xzy229391326
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-8-31
收藏
 问题点数:0 回复次数:0 
新手,关于for循环有些不理解
程序代码:
#include <stdio.h>
#define SIZE 10
#define PAR 72
int main()
{
int index,score[SIZE];
int sum = 0;
float average;

printf("Enter %d golf scores:\n",SIZE);
for (index = 0;index < SIZE;index++)
scanf("%5d",&score[index]); //读取10个分数 

printf("The scores read in are as follows:\n");
for (index = 0;index < SIZE;index++)
printf("%5d",score[index]); //验证输入
printf("\n");

for (index = 0;index < SIZE;index++)
sum += score[index]; //求总分数
average = (float) sum /SIZE; //求平均分
printf("Sum of scores = %d, average = %.2f\n",sum,average);
printf("That's a handicap of %.0f.\n",average-PAR);

return 0;
}


对于其中的for循环的判定条件有些不能理解,还有尝试去掉第二个for语句,编译出来的验证输入那条是单个输出并且循环,求解答
搜索更多相关主题的帖子: average 
2016-08-16 19:47
快速回复:新手,关于for循环有些不理解
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011149 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved