| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 833 人关注过本帖
标题:C语言问题,谁能帮下忙,感激不尽
取消只看楼主 加入收藏
kaiqi
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-11-29
收藏
 问题点数:0 回复次数:2 
C语言问题,谁能帮下忙,感激不尽
Sample Input


5
John 9.5
Tom 10
Cate 6
King 7.5
Peter 4

Sample Output


Tom 10.0
John 9.5
King 7.5
#include"stdio.h"
void main()
{
    int n,i,j;
    int mark[20];
    char name[20];
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%s,%d",&name[i],&mark[i]);
    }
    for(j=n;j>=n-2;j--)
    {
        for(i=1;i<=j;i++)
        {
            if(mark[i]>mark[i+1])
                mark[i+1]=mark[i];
        }
        printf("%s,%d\n",name[j],mark[j]);
    }
}
不知道哪里出了问题?
谁能帮下忙,感激不尽!!!
搜索更多相关主题的帖子: C语言 感激不尽 
2008-11-29 15:59
kaiqi
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-11-29
收藏
得分:0 
原题描述:
Description

You are asigned to work for the 2010 aisan games as a programmer. Given a number of athlete's marks, Your task is to find the first three highest marks.

Input

First line is an integer n, the number of marks, n < 100. Each line of the following n lines contains the athlete's name(with no more than 20 characters) and his marks(no more than 1000). None of them has the same mark as the other.

Output

Output The three athlete's name with the highest marks descendingly. The name and mark is separated by one space.The mark has only one decimal.

Sample Input


5
John 9.5
Tom 10
Cate 6
King 7.5
Peter 4

Sample Output


Tom 10.0
John 9.5
King 7.5
2008-11-29 16:00
kaiqi
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-11-29
收藏
得分:0 
谢谢了 果然是过手如云啊 知道了 输入是要用二维数组 谢谢各位大侠
2008-11-29 21:44
快速回复:C语言问题,谁能帮下忙,感激不尽
数据加载中...
 
   



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

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