题目提示:定义3个一维整型数组a、b、c,分别存放两个整数集合和它们的并集。现将a数组中的全体元素放入c数组,再依次判断b数组中的每一个元素b[i],如果b[i]不属于a数组,则将b[i]加入c数组。
我编的程序:
#include
using namespace std;
void input(int a[],int b[], int c[], int n)
{
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i];
}
void output(int a[],int b[], int c[], int n,int m)
{
int i=0, j=0, k = 1000, l = 1000;
{
while (i < m&&j < n)
{
{c[n] = a[n]; }
if (a[i] == b[j])
{
cout << c[i];
}
else if (a[i] > b[j])
{
{c[i] += (b[i]-b[j]); }
j++;
}
else
{
{c[j] += (a[i]-a[j]); }
cout << c[i];
j++;
}
}
}
}
int main (void)
{
cout << "输入数组两个数组" << '\n';
const int n=1000,i=1000,l=1000;
int a[n];
int b[i];
int c[l];
input; a[i], b[i], c[i];
output; a[i], b[i], c[i];
system("PAUSE");
return 0;
}
但是output 我不指导怎么向main里面插入
所以出来的程序是这样的
求各位大神,前辈解决………………