Current location - Health Preservation Learning Network - Healthy weight loss - The next freshman, the school opened a C language course, which was deeply difficult. The teacher assigned an assignment, but I still have no idea after thinking about it for a long time. I hope you w
The next freshman, the school opened a C language course, which was deeply difficult. The teacher assigned an assignment, but I still have no idea after thinking about it for a long time. I hope you w
The next freshman, the school opened a C language course, which was deeply difficult. The teacher assigned an assignment, but I still have no idea after thinking about it for a long time. I hope you will be hi. 1, select sorting.

void sort(int a[],int n)

{

int i,j,temp

for(I = 0; I & ltn;; i++)

{

for(j = I+ 1; j & ltn; j++)

{

if(a[I]& gt; a[j])

{

temp = a[I];

a[I]= a[j];

a[j]= temp;

}

}

}

}

}

2, bubble sorting

void sort(int a[],int n)

{

int i,j,temp

for(I = 0; I & ltn;; i++)

{

for(j = 0; j & ltn-I; j++)

{

if(a[j]& gt; a[j+ 1])

{

temp = a[j];

a[j]= a[j+ 1];

a[j+ 1]= temp;

}

}

}

}

}