📄 sortme.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 + -