#include <stdio.h>

#include <stdlib.h>


#define N (sizeof scores / sizeof scores[0]) 


void swap(char** a, char** b)

{

    char* t  = *a;

    *a = *b;

    *b = t;

}


void bubble_sort(char* string_list[], int count)

{

    int i, j;

    for(i = count - 1; i > 0; --i)

        for(j = 0; j < i; ++j)

            if (string_list[j][0] > string_list[j + 1][0])

                swap(&string_list[j], &string_list[j + 1]);

}


int main()

{

    char* scores[] =

    {

        "Charlie 90",

        "David 95",

        "Bob 85",

        "Alice 70",

        "Eve 100", // 일부러 콤마 남겨두는 것임. 배열 늘릴 때 복붙하기 좋도록

    };


    int i, count;

    char name[80];


    bubble_sort(scores, N);

    for(i = 0; i < N; ++i)

    {

        for(count = 0; scores[i][count] != ' '; ++count)

            name[count] = scores[i][count];

        name[count] = 0;

        printf("%s %s\\n", scores[i] + count + 1, name);

    }

    system("pause");


    return 0;

}


char* [] 형태의 변수라 순서를 바꿀수 있는데 따로 인덱스아닌 인덱스를 만들어 정렬하는게 웃겨서.