题解 | #有序序列插入一个整数#
有序序列插入一个整数
https://www.nowcoder.com/practice/444e87f938464906a1649cff236b102b
#include <stdio.h> void SortedPrint(int n) { int tmp = 0; int arr[999] = { 0 }; for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } for (int i = n; i <= n; i++) { scanf("%d", &arr[i]); } for (int i = 0; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (arr[i] > arr[j]) { tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; } } printf("%d ", arr[i]); } } int main() { int n = 0; scanf("%d", &n); SortedPrint(n); return 0; }