1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#include <stdio.h>
int main(void)
{
float variable[10];
int i;
for(i=0; i< 10; i++)
{
scanf("%f", &variable[i]);
}
printf("numbers in array: \n");
for(i=0, i< 10, i++)
{
printf("%f -- ", variable[i]);
}
printf("\n\n");
printf("lowest: \n");
float lowest;
lowest = variable[0];
for(i=0, i< 10, i++)
{
if(lowest > variable[i])
{
lowest = variable[i];
}
}
printf("%f\n", lowest);
int start;
int minPos;
float change;
for(start=0, start < 10, start++)
{
lowest = variable[start];
minPos = start;
for(i=start; i< 10; i++)
{
if(lowest > variable[i])
{
lowest = variable[i];
minPos = i;
}
}
change = variable[minPos];
variable[minPos] = variable[start];
variable[start] = change;
}
printf("sorted numbers: \n");
for(i=0, i< 10, i++)
{
printf("%f -- ", variable[i]);
}
return 0;
}
|