| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 467 人关注过本帖
标题:大侠,帮忙分析一下这个歌手大赛程序。
只看楼主 加入收藏
minhong2010
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2010-10-7
结帖率:75%
收藏
已结贴  问题点数:10 回复次数:4 
大侠,帮忙分析一下这个歌手大赛程序。
#include<stdio.h>
void main()
{
    int score[10];
    int i,sum=0,max=score[0],min=score[9];
    printf("please input singer's score:\n");
    for(i=0;i<10;i++)
    {
        scanf("%d",&score[i]);
        printf("the number %d is\n", i);
        printf("%d\n",score[i]);
        if(score[i]>max)    max=score[i];
        if(score[i]<min)    min=score[i];
        sum+=score[i];
    }
    printf("The singer's average score is %f \n",(sum-max-min)/8);
}
搜索更多相关主题的帖子: 大赛 歌手 
2010-10-29 10:58
outsider_scu
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:3
帖 子:430
专家分:1333
注 册:2010-10-21
收藏
得分:5 
程序代码:
#include<stdio.h>
void main()
{
    int score[10];
    int i,sum=0,max=0,min=100; /*这个地方最好,分配给MAX和MIN确定的值,你那么分配的话,好像是随机值。*/
    printf("please input singer's score:\n");
    for(i=0;i<10;i++)
    {
        scanf("%d",&score[i]);
        printf("the number %d is\n", i);
        printf("%d\n",score[i]);
        if(score[i]>max)    max=score[i];
        if(score[i]<min)    min=score[i];
        sum+=score[i];
    }
    printf("The singer's average score is %.2f \n",(sum-max-min)/8.0); /*这个地方要除以8.0,否则,得到的就将是整型,是不能变成浮点型输出的*/
}

编程的道路上何其孤独!
2010-10-29 11:08
小白来学习
Rank: 2
等 级:论坛游民
帖 子:20
专家分:33
注 册:2010-7-28
收藏
得分:2 
楼上正解
2010-10-30 13:06
zzgzzg00
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:2
帖 子:388
专家分:627
注 册:2010-8-2
收藏
得分:1 
嗯 嗯  

粗心是大敌
2010-10-30 16:37
gds545898817
Rank: 2
等 级:论坛游民
帖 子:6
专家分:11
注 册:2010-10-30
收藏
得分:2 
printf("the number %d is\n", i);
改成printf("the number %d is\n", i+1);
会好看点!
2010-10-30 18:15
快速回复:大侠,帮忙分析一下这个歌手大赛程序。
数据加载中...
 
   



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

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