Skip to content

Commit

Permalink
Create sort.c
Browse files Browse the repository at this point in the history
  • Loading branch information
LaiTial authored Sep 3, 2019
1 parent 0b9d4c1 commit 670dc87
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions MakeAProgram/CheckSort/sort.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <stdio.h>

int main(void)
{
int ar[] = { 69, 10, 30, 2, 16, 8, 31, 22 };
int m;
int temp;

for (int i = 0; i < 7; i++)
{
m = i;

for (int j = i + 1; j < 8; j++)
{
if (ar[j] < ar[m])
{
m = j;
}
}

temp = ar[i];
ar[i] = ar[m];
ar[m] = temp;
}

for (int i = 0; i < 8; i++)
{
printf("%d", ar[i]);

if (i != 7)
printf(", ");
}

puts("");
}

0 comments on commit 670dc87

Please sign in to comment.