c语吧 关注:409贴子:549
  • 0回复贴,共1

求解,求帮助

只看楼主收藏回复

请问一下,这个程序哪里错了呢,应该怎么改
谢谢
#include <stdio.h>
#define number 10
int main()
{
int sum_x(int a[number]);
int sum_y(int b[number]);
int sum_x2(int c[number]);
int sum_xy(int d[number],int e[number]);
int x[number],y[number],i,a,b,c,d,e,f,n;
printf("请输入各个x的值");
for (i=0;i<number;i++)
scanf("%d",&x[i]);
printf("请输入各个y的值");
for (i=0;i<number;i++)
scanf("%d",&y[i]);
c=sum_x(x);
d=sum_y(y);
e=sum_x2(x);
f=sum_xy(x,y);
n=number;
a=(f*c-d*e)/(c*c-n*e);
b=(c*d-n*f)/(c*c-n*e);
printf("a=%d,b=%d\n",a,b);
return 0;
}
/*****求x的和*******/
int sum_x(int a[number])
{
int j,sum=0;
for (j=0;j<number;j++)
sum=sum+x[j];
printf("x的和为%d\n",sum);
return sum;
}
/*****求y的和*******/
int sum_y(int b[number])
{
int j,sum=0;
for (j=0;j<number;j++)
sum=sum+y[j];
printf("y的和为%d\n",sum);
return sum;
}
/*****求x平方的和*******/
int sum_x2(int c[number])
{
int j,sum=0;
for (j=0;j<number;j++)
sum=sum+x[j]*x[j];
printf("x平方的和为%d\n",sum);
return sum;
}
/*****求x乘y的和*******/
int sum_xy(int d[number],int e[number])
{
int j,sum=0;
for (j=0;j<number;j++)
sum=sum+x[j]*y[j];
printf("x乘y的和为%d\n",sum);
return sum;
}


IP属地:四川1楼2015-05-18 21:17回复