|
发表于 2003-4-13 02:04:21
|
显示全部楼层
(1)
scanf("%f \t",a); --> scanf("%f \t", &a);
(2)
#include <stdio.h>
float max(float a[4]);
int main()
{
float b[4];
float c; // First error
c = max(b);
printf("%f \n", c);
return 1;
}
float max(float a[4])
{
int i;
float t;
float max;
for(i=0;i<4;i++)
{
scanf("%f", &a); // Second
}
for(i=0;i<4-1;i++) // Third, only need loop (n - 1), or ...
{
if(a>a[i+1])
{
// Shift from lower to higher
t = a[i+1]; // Fourth, should save bigger
a[i+1] = a; // you saved the smaller
a = t; //
printf("%s %i %s %f \t %f \t %f \t %f \t %f \n", "round = ", i, " t= ", t, a[0], a[1], a[2], a[3]);
}
}
max = a[3];
return max;
} |
|