编写一个数组排序的代码

答:// 定义数组 int arr[] = {3, 1, 4, 5, 2};// 数组排序 for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (arr[i] < arr[j]) { int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } }

猜你喜欢

转载自blog.csdn.net/weixin_42588555/article/details/129502223