⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sortme.c

📁 C.Game.Programming.For.Dummies.原码
💻 C
字号:
#include <stdio.h>

#define SIZE 6      //size of the array

void sort(int *array,int size);

void main()
{
    int lotto[] = { 10, 48, 1, 37, 6, 24 };
    int i;

    printf("Here is the array unsorted:\n");

    for(i=0;i<SIZE;i++)
        printf("%i\t",lotto[i]);

    printf("\nAnd here is the sorted array:\n");

    sort(lotto,SIZE);

    for(i=0;i<SIZE;i++)
        printf("%i\t",lotto[i]);

}

void sort(int *array,int size)
{
    int a,b,temp;

    for(a=0;a<size-1;a++)
        for(b=a+1;b<size;b++)
            if(array[a] > array[b])
            {
                temp=array[b];
                array[b] = array[a];
                array[a] = temp;
            }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -