自然语言就是简单的冒泡法
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
void sort1(int a[11])//冒泡法排序
{
int i,j,temp;
for (i=0;i<10;i++)
{
for (j=i+1;j<11;j++)
{
if (a[i]>a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
}
void main()
{
int a[11]={56, 3, 45, 2, 9, 5, 4, 8, 13, 7, 6};
int i,j;
printf("before sorting:\n");
for (i=0;i<11;i++)
{
printf("%d ",a[i]);
}
printf("\nafter sorting,small->big\n");
sort1(a);
for (i=0;i<11;i++)
{
printf("%d ",a[i]);
}
printf("\nafter sorting,big->samll\n");
for (i=10;i>=0;i--)
{
printf("%d ",a[i]);
}
printf("\n");
system("pause");
}
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/5243fbf2b211931303a77b2064380cd790238dbe?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)