ALL > Computer and Education > courses > university courses > undergraduate courses > An Overview of Computer Science > zstu-(2019-2020-1) class >
2019529628042 Version 0
👤 Author: by dawitdemissie4gmailcom 2019-11-02 10:02:58

homework4-2


#include<stdio.h>

int main()

{

int a[100], n, m, i, j;

while (scanf("%d", &n) != EOF)

{

for (i = 0; i < n; i++)

{

scanf("%d", &a[i]);

}

for (i = 0; i < n - 1; i++)

{

for (j = 0; j < n - i - 1; j++)

{

if (a[j] > a[j + 1])

{

m = a[j];

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

a[j + 1] = m;

}

}

}

for (i = 0; i < n; i++)

{

printf("%d ", a[i]);

}

printf("\n");

}



return 0;

}

Please login to reply. Login

Reversion History

Loading...
No reversions found.