改错,改错,改错啊
#include<stdio.h>#define i 100
void in_data(float stock_price[][4],int i);
void out_list(float stock_price[][4],int i);
void aver(float stock_price[][5],int i);
int main()
{
in_data(float stock_price[][4],int i);
out_list(float stock_price[][4],int i);
aver(float stock_price[][5],int i);
}
void in_data(float stock_price[][4],int i)
{
printf("\t请依次输入每个西瓜的实际重量和猜测重量(以-1结束)\n");
do
{
printf("\n\t请输入第%d个西瓜的实际重量和猜测重量:",i+1);
ccanf("%f",&stock_price[i][o]);
ccanf("%f",&stock_price[i][1]);
i++;
}
while(stock_price[i][0]=-1&&stock_price[i][1]=-1);
return i;
}
void out_list(float stock_price[i][4],int i)
{
int j;
for(j=0;j<=i,j++)
{
stock_price[j][3]=stock_price[j][1]-stock_price[j][0];
stock_price[j][4]=100*stock_price[j][3]/stock_price[j][0];
printf("\t%lf \t%.5lf%",stock_price[j][3],stock_price[j][4]);
}
}
void aver(float stock_price[i][4],int i)
{
int j;
float sum=0;
float sun=0;
for(j=0,j<=i,j++)
sum+=stock_price[i][3];
sun=stock_price[i][4];
stock_price[i+1][3]=sum/(i+1);
stock_price[i+1][4]=sun/(i+1);
printf("\t%lf \t%.5lf%", stock_price[i+1][3],stock_price[i+1][4];
}