求助 一道C语言的课程设计题

来源:百度知道 编辑:UC知道 时间:2024/05/16 18:47:05
把a数组中的n个数和b数组中逆序的n个数一一对应相加,求平方,结果存放在c数组中。例如;若a数组中的值是;1,3,5,7,8。b数组中的值是;2,3,4,5,8。运算后c中存放的数据是;81,64,81,100,100
要详细的过程

#include (stdio.h)
main(){
int a[]={1,3,5,7,8};
int acount=a.length;
int b[]={2,3,4,5,8};
int bcount=b.length;
int c[];
for(int i = 0;i<bcount;i++){
int temp;
temp = b[i];
b[i] = b[bcount-1];
b[bcount-1] = temp;
}
for(int i = 0;i<acount;i++){
c[i]=(a[i]+b[i])*(a[i]+b[i]);
}
}

让我们找给你?

提供给你两个方法
1 用冒泡法,将b里的数重新排列,然后再和a相加,平方以后附给c

2 设一个int型变量x,初始值为0,然后for(x=0;x<n;x++)将a[x+1]+b[n-x]相加,平方以后附给c