对整数排序
问题描述
从标准输入读取一列整数,并且按照升序排列它们,最后打印这个列表。
C代码
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//该函数由qsort调用,用于比较整型值
int compare_integers(void const *a, void const *b)
{
register int const *pa = a;
register int const *pb = b;
return *pa > *pb ? 1 : *pa < *pb ? -1 : 0;
}
int main()
{
int *array;
int n_values;
int i;
//观察共有多少个值
printf("how many values are there?");
if (