napisz program w turbo c++ i DEV który sumuje 2 tablice jednowymiarowe 4 elementowe i wypisze je w 3 tablicy PILNE POTRZEBA NA ZARAZ
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
Co to "DEV"?
Program:
#include <cstdio>
int* sum(int* a1, int* a2)
{
int* new_a = new int[4];
for (int i = 0; i<4; i++)
new_a[i] = a1[i]+a2[i];
return new_a;
}
int main()
{
int* array1 = new int[4];
int* array2 = new int[4];
int i;
for (i = 0; i<4; i++)
scanf("%i", &array1[i]);
for (i = 0; i<4; i++)
scanf("%i", &array2[i]);
int* sum_ = sum(array1, array2);
printf("-----\n");
for (i = 0; i<4; i++)
printf("%i\n", sum_[i]);
}