Create a thread that will use a runner function and from the thread function (e.g. runner) call the Fibonacci function to generate the Fibonacci series and store them in the array. Use the parameter supplied in the function runner in order to determine how many Fibonacci numbers must be generated.
1
Expert's answer
2013-01-28T12:27:04-0500
# include <iostream> #include <vector> using namespace std; //returns std::vector<int> fib_n(int n) { std::vector<int> dp(n + 1); dp[1] = 1; if (n<2) return dp; dp[2] = 1; if (n<3) return dp; for (int i = 3; i <= n; i++) { dp[i] = dp[i - 1] + dp[i - 2]; } return dp; } void print (vector<int> a){ for(int i=1;i<a.size();i++){ cout<<a[i]<<" "; } }
int main(){ setlocale( LC_ALL,"Russian" ); vector<int> c; int n; cout<<"Enter n : "; cin>>n;
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment