王道8.3综合应用
文豪必上岸
这个作者很懒,什么都没留下…
展开
-
8.3交换排序综合应用7
#include<stdio.h> #include<stdlib.h> #include<math.h> void Sort(int A[],int n){ int left=-1,right=n,i=0,temp; while(i<right){ //此处不能小于n,如果小于n的话就最后一个颜色会和第二个颜色颠倒 if(A[i]==1){ left++; temp=A[i]; A[i]=A[left]; .原创 2021-10-23 19:11:02 · 80 阅读 · 0 评论 -
8.3交换排序综合应用6
#include<stdio.h> #include<stdlib.h> #include<math.h> void Sort(int A[],int n){ int temp; for(int i=0;i<=n-1;i++){ for(int j=i+1;j<=n-1;j++){ if(A[i]>A[j]){ temp=A[i]; A[i]=A[j]; A[j]=temp; } } } } vo.原创 2021-10-23 17:22:02 · 70 阅读 · 0 评论 -
8.3交换排序综合应用5
#include<stdio.h> #include<stdlib.h> #include<math.h> void Sort(int A[],int n){ int temp,j=0; while(j<=6){ for(int i=n-1;i>j;i--){ if(A[i]<A[i-1]){ temp=A[i]; A[i]=A[i-1]; A[i-1]=temp; } } j++; } .原创 2021-10-23 16:59:39 · 56 阅读 · 0 评论 -
8.3交换排序综合应用4
#include<stdio.h> #include<stdlib.h> #include<math.h> int partition(int A[],int low,int high){ int num=rand()%(high-low+1)+low; //rand函数rand()%(high-low+1)+low int num2=low,pivot,temp2; temp2=A[num2]; A[num2]=A[num]; A[num]=.原创 2021-10-23 15:30:19 · 61 阅读 · 0 评论 -
王道8.3综合应用题3
#include<stdio.h> #include<stdlib.h> #include<math.h> int partition(int A[],int low,int high){ int temp=A[low]; while(low<high){ while(A[high]%2==0 && low<high){ high--; } A[low]=A[high]; while(A[low]%2!=0 &.原创 2021-10-23 03:26:01 · 75 阅读 · 0 评论