From edd0873377a1e5af16a340f095397b78329be02c Mon Sep 17 00:00:00 2001 From: p2mkf5jco <2986203583@qq.com> Date: Fri, 18 Feb 2022 11:23:57 +0800 Subject: [PATCH] =?UTF-8?q?Add=20=E9=80=89=E6=8B=A9=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 选择排序 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 选择排序 diff --git a/选择排序 b/选择排序 new file mode 100644 index 0000000..ae7bb75 --- /dev/null +++ b/选择排序 @@ -0,0 +1,28 @@ +#include //时间复杂度o(n^2) +void choice(int *a,int n) +{ + int i,j,temp; + for(i=0;ia[j]) + { + temp=a[i]; + a[i]=a[j]; + a[j]=temp; + } + } + } +} +int main(int argc, char *argv[]) +{ + int a[10]={2,4,7,1,6,9,8,3,0,5}; + int i; + choice(a,10); + for(i=0;i<10;i++) + printf("%d ",a[i]); + + printf("\n"); + return 0; +} \ No newline at end of file