TU-Programmieren_2/lab2/task.cpp
2025-04-09 10:22:44 +02:00

30 lines
657 B
C++

#include <iostream>
#include <vector>
#include <cmath>
std::vector<double> addSequenz(std::vector<double> a, std::vector<double> b){
int shortest = a.size();
std::vector<double> erg={};
if(a.size()>b.size()) {
shortest=b.size();
}
for (int i = 0 ; i < shortest ; i++){
double ad = a[i];
double bd = b[i];
erg.push_back(ad+bd);
}
return erg;
};
int main(){
std::vector<double> a = {5,10,20,30};
std::vector<double> b = {5,3,8};
//expect 10,13,28
std::vector<double> c = addSequenz(a,b);
std::cout << c[0] << ',' << c[1] << ',' << c[2] << std::endl;
return 1;
}