if(maxi<eingabe[i])
{
maxi=eingabe[i];
}
if (eingabe[i]<mini)
{
mini=eingabe[i];
}
here maxi
and mini
are not initialized so first comparison will not be fine. initialize those variables.
you can initialize mini
and maxi
to eingabe[0]
You code for bubble sort
is not complete.
for(i=0;i<N;i++)
{
if (eingabe[i]>eingabe[i+1])
{
temp=eingabe[i];
eingabe[i]=eingabe[i+1];
eingabe[i+1]=temp;
}
}
there should be 2 for loops. one for loop means only one run through the array. it will not sort the array. the loops should be,
for(j=0;j<N-1;j++)
for(i=0;i<N-1-j;i++)
{
//write the if statement
}
in this part of code i think you are getting the min and max values
for(i=0;i<N;i++)
{
if(maxi<eingabe[i])
{
maxi=eingabe[i];
}
if (eingabe[i]<mini)
{
mini=eingabe[i];
}
printf("\nDer Minimalwert ist: %i",mini);
printf("\nDer Maximalwert ist: %i",maxi);
change it to
mini=eingabe[0];
maxi=eingabe[0];
for(i=0;i<N;i++)
{
if(maxi<eingabe[i])
{
maxi=eingabe[i];
}
if (eingabe[i]<mini)
{
mini=eingabe[i];
}
}
printf("\nDer Minimalwert ist: %i",mini);
printf("\nDer Maximalwert ist: %i",maxi);