我寫的代碼,但我不獲得最大的價值如何找到最大值尋找最小和最大
#include <stdio.h>
int main(void)
{
double temp[0];
float max,min;
float i;
short c,j,k;
float sum=0;
float nu[c];
printf("Number of values :");
scanf("%f",&i);
for (c=1;i>=c;c++)
{
printf("values=");
scanf("%f",&nu[c]);
nu[c]=temp[0];
for (j = 0; i>=j; j++)
{
if (temp[0]> nu[c])
{
// nu[c]=temp[0];
max = temp[0];
}
}
sum = sum + nu[c];
}
printf("sum = %f \n",sum);
printf("maximum value = %f\n",max);
}
可能重複的[找到sum,min,max與數組](http://stackoverflow.com/questions/3547633/finding-sum-min-max-with-array)(來自同一作者)。 – paxdiablo 2010-08-24 11:16:47