摘要: #include <bits/stdc++.h> using namespace std; int main(){ int a[]={7,4,8,9,2,6}; for(int i=1;i<6;i++){ for(int j=i;j>0;j--){ if(a[j]<a[j-1]){ swap(a[j 阅读全文
posted @ 2024-04-05 09:40 fushuxuan1 阅读(11) 评论(0) 推荐(0)
摘要: #include <bits/stdc++.h> using namespace std; //基本思想:从数组的未排序区域选出一个最小的元素, //把它与数组中的第一个元素交换位置; //然后在从剩下的未排序区域中选出一个最小的元素 //把它与数组中的第二个元素交换位置。 //重复上述过程,直到数 阅读全文
posted @ 2024-04-05 08:53 fushuxuan1 阅读(14) 评论(0) 推荐(0)
摘要: #include <bits/stdc++.h> using namespace std; int main(){ int a[]={7,4,8,9,2}; for(int i=0;i<5;i++){ for(int j=i+1;j<5;j++){ if(a[i]>a[j]){ swap(a[i], 阅读全文
posted @ 2024-04-05 08:30 fushuxuan1 阅读(12) 评论(0) 推荐(0)