| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 588 人关注过本帖
标题:帮忙解释下,万谢
只看楼主 加入收藏
a132266
Rank: 2
等 级:论坛游民
帖 子:86
专家分:20
注 册:2015-3-26
结帖率:66.67%
收藏
 问题点数:0 回复次数:4 
帮忙解释下,万谢
#include<stdio.h>
#define SIZE 10
#define PAP  72
int main(void)
{
   
   
    int index, score[SIZE];
    int sum = 0;
    float average ;
   
    printf("Enter %d golf scores: \n",SIZE);
    for (index = 0; index < SIZE ; index++)     //     int index, score[SIZE];      
    scanf("%d",&score[index]);                  //    scanf("%d",&score[index]);  这里 score[10]  然后 scanf 取地址了 10个 index吗  感觉上应该是10个score啊         
    printf("The scores read in are as followa: \n");
    for(index = 0; index < SIZE; index++)
    printf("%5d",score[index]);
    printf("\n");
}
搜索更多相关主题的帖子: average include scores Enter 
2015-04-07 00:37
zhou78yang
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:18
专家分:100
注 册:2014-3-18
收藏
得分:0 
好好看书嘛,别急着问问题,多看几页就看到了嘛
2015-04-07 00:50
Vsnow
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:124
专家分:145
注 册:2015-1-3
收藏
得分:0 
希望对楼主有用
#include<stdio.h>
#define SIZE 10
#define PAP  72
int main(void)
{
   
   
    int index, score[SIZE];
    int sum = 0;
    float average ;
   
    printf("Enter %d golf scores: \n",SIZE);
    for (index = 0; index < SIZE ; index++)     //     int index, score[SIZE];      
    scanf("%d",&score[index]);                  //    scanf("%d",&score[index]);  这里 score[10]  然后 scanf 取地址了 10个 index吗  感觉上应该是10个score啊
    /*比如 scanf("%d",&a);中的&是“地址运算符”,&a指a在内存中的地址
    scanf的作用就是按照a在内存的地址讲a的值存进去*/
    printf("The scores read in are as followa: \n");
    for(index = 0; index < SIZE; index++)
    printf("%5d",score[index]);
    printf("\n");
}
2015-04-08 10:49
扯淡青春
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-4-8
收藏
得分:0 
这就是C语言吗?
2015-04-08 11:14
code力力
Rank: 5Rank: 5
来 自:宜昌
等 级:职业侠客
威 望:2
帖 子:215
专家分:338
注 册:2015-1-12
收藏
得分:0 
这里的score和index是不可分割的。

好比:score是楼梯的入口,index是代表楼层。你要去某一栋楼找一个人,你就必须要知道这个楼的入口和那个人所在的楼层。

回到代码,score是数组首地址,index是索引。score[0] 就是数组第一个元素,score[1]是第二个......

你用scanf不是把值赋给score(除非你只给score[0]赋值),也不是给index ,而是给score[index],也就是一个数组元素。

数组的概念没弄懂,看书吧。

你醒了?快起来敲代码!!
2015-04-08 11:19
快速回复:帮忙解释下,万谢
数据加载中...
 
   



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

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