Problem polega na tym ze np. przykladowe wejscie u mnie wyglada tak:
Kod: Zaznacz cały
5
10
-10
0
15
7
Kod: Zaznacz cały
5
10 -10 0 15 7
Kod: Zaznacz cały
#include <stdio.h>
void wypisz(int a[],int n)
{
for (int i=0;i<n;i++)
printf("%d",a[i]);
}
void wypelnij(int a[], int n)
{
int x;
for (int i=0;i<n;i++)
{
scanf("%d",&x);
a[i]=x;
}
}
void bubblesort(int a[], int n)
{
int i, j, temp;
for (i = 0; i<n-1; i++)
{
for (j=0; j<n-1-i; j++)
{
if (a[j] > a[j+1])
{
temp = a[j+1];
a[j+1] = a[j];
a[j] = temp;
}
}
}
}
int main()
{
int n;
scanf("%d",&n);
int a[n];
wypelnij(a,n);
bubblesort(a,n);
wypisz(a,n);
return 0;
}