1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include <iostream>
#include <iomanip>
using namespace std;
void sum(int [], int [], int [], int);
int main()
{
const int arraySize = 20;
int first_array[arraySize] ={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,18,20};
int second_array[arraySize] = {11,12,13,14,15,16,17,18,19,20, 21,22,23,24,25,26,27,28,29,30};
int third_array[arraySize] = {};
cout << setw(7) << "Array 1" << setw(3) << "+" << setw(10)
<< "Array 2" << setw(3) << "=" << setw(10) << "Array 3" << endl;
sum( first_array, second_array, third_array, arraySize);
}
void sum(int a[], int b[], int c[], int sizeArray)
{
for (int i = 0; i < sizeArray; ++i)
{
c[i]= b[i] + a[i];
cout << setw(7) << a[i] << setw(3) << "+" << setw(10)
<< b[i] << setw(3) << "=" << setw(10) << c[i] << endl;
}
}
|