バブルソートC

#include <stdio.h>

int main()
{
    int a[5] = {3, 5, 6, 7, 2};
    int i, j, temp;

    for (i = 0; i < 4; i++)
    {
        for (j = i + 1; j < 5; j++)
        {
            if (a[i] < a[j])
            {
                temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
    }

    for (i = 0; i < 5; i++)
    {
        printf("%d", a[i]);
    }
}

おすすめ

転載: www.cnblogs.com/zpchcbd/p/11783726.html