题解 | #牛牛的排序#
牛牛的排序
https://www.nowcoder.com/practice/26a0c92e9266443887a3bf81aff8e188
#include void sort(int *array, int n){ int i, j,temp; for(int i = 0; i < n ; i++){ for(int j = i+1; j < n; j++){ if(array[j]<array[i]){//排序 temp = array[j]; array[j] = array[i]; array[i] = temp; } } } for(int i = 0; i < n; i++){ printf("%d ",array[i]); } } int main() { int n; scanf("%d\n", &n); int array[100] = {0}; int *p = array; for(int i = 0; i < n; i++){ scanf("%d\n", &array[i]); } sort(array,n); return 0; }
为数组排序