Varianta 62 / Subiectul 3 / Problema 3 |
#include<iostream.h> void fibo(int n, int v[100]) { int x,y,z,k=0; x=1;y=1; v[1]=1; v[2]=1; k=2; while(k<n) { z=x+y; if(z%2==1) v[++k]=z; x=y; y=z; } } void main() { int n,i, v[100]; cin>>n; fibo(n,v); for(i=1;i<=n;i++) cout<<v[i]<<" "; } |