Problem1911--【高级语言程序设计】11.7冬奥会金牌排行榜

1911: 【高级语言程序设计】11.7冬奥会金牌排行榜

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 1  Solved: 1
[Submit] [Status] [Web Board] [Creator:]

Description

编写一个程序,请用如下结构体类型编程,输入 n 以及 n 个国家的国名及其获得的金牌数,然后对国名进行排序。

  1. typedef struct country
  2. {
  3. char name[N];
  4. int goldMedal;
  5. }COUNTRY;

Input

输入 n 个国家; 输入n 个国家的国名及其获得的金牌数。 

Output

对国名进行排序,输出国名及其获得的金牌数。

Sample Input Copy

3
China 15
America 12
Japan 10

Sample Output Copy

Sorted results:
America:12
China:15
Japan:10

HINT

算法思想

题意可采用顺序排序,即使用一对嵌套循环进行排序。 顺序排序包括选择排序、插入排序、冒泡排序。

#include  <stdio.h>
#include  <string.h>
#define   M  150 //最多的字符串个数
#define   N  10  //每个字符串的最大长度
struct country
{
    //=======begin=======

    //========end========
};
void SortString(struct country c[], int n);
int main(void)
{
    //=======begin=======





    //========end========
}
//函数功能:按国名字典顺序排序
void SortString(struct country c[], int n)
{
    //=======begin=======





    //========end========
}

Source/Category