C++问题 急切请求帮助!

来源:百度知道 编辑:UC知道 时间:2024/05/15 03:32:23
Write a function
void max(int a[ ], int b[ ], int c[ ], int n)
that computes c[i] = max(a[i], b[i]), i=0,…,n-1. Write a main program that illustrates the use of this function (it must display a[ ], b[ ], and c[ ]).
大侠 这个有错误啊 再请帮忙调试

#include<iostream>
using namespace std;
int bigger(int a,int b)
{
return (a>b?a:b);
}
void max(int a[ ], int b[ ], int c[ ], int n)
{
for(int i=0;i<n;i++)
c[i]=bigger(a[i],b[i]);

}
void main()
{
int a[10]={2,3,6,8,0,4,22,112,445,67};
int b[10]={4,63,1,4,5,6,272,1812,5,6};
int c[10];
max(a,b,c,10);

for(int i=0;i<10;i++)
{
cout<<a[i]<<" ";
}
cout<<endl;

for( i=0;i<10;i++)
{
cout<<b[i]<<" ";
}
cout<<endl;

for( i=0;i<10;i++)
{
cout<<c[i]<<" ";
}
cout<<endl;
}