Răspuns:
#include <iostream>
#include <vector>
using namespace std;
int main(){
int n;
cout << "Introduceti lungimea sirului n=";
cin >> n;
vector <int> sir;
sir.push_back(0);
sir.push_back(1);
for (int i = 2;i < n; i++) {
sir.push_back(sir.at(i - 1) + sir.at(i - 2));
}
cout << "Sirul obtinut:\n";
for (int i = 0;i < sir.size(); i++) {
cout << sir.at(i) << " ";
}
return 0;
}
Explicație: