// ΛΥΣΕΙΣ ΘΕΜΑΤΩΝ ΣΕΠΤΕΜΒΡΗ 2016 // ΘΕΜΑ 2. #include #define FOR(i,start,stop) for(int i = start; i < stop; i++) using namespace std; void sum(int n, int a[], int b[], int c[]){ if (n > 0){ c[n-1] = a[n-1] + b[n-1]; n--; sum(n, a, b, c); } } void inner(int n, int a[], int b[], float &res){ if (n > 0) { res += a[n-1]*b[n-1]; n--; inner(n, a, b, res); } } int main(){ int n; cout << "Δώσε το n\n"; cin >> n; int *x = new int[n], *y = new int[n], *z = new int[n]; float res = 0.0; FOR(i,0,n) cin >> x[i]; FOR(i,0,n) cin >> y[i]; sum(n,x,y,z); FOR(i,0,n) cout << z[i] << "\t"; cout << "\n"; inner(n,x,y,res); cout << "inner(x,y) = " << res << endl; delete [] x, y, z; return 0; }