Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <malloc.h>
- int Fib(int N)
- {
- if(N == 0 || N == 1)
- return N;
- else return Fib(N-1)+Fib(N-2);
- }
- int *InvFib(int vect[], int tam)
- {
- int *v = (int *)malloc(sizeof(int) * tam);
- for(int i=0; i<tam; i++)
- v[tam-i-1] = Fib(vect[i]);
- return v;
- }
- void main()
- {
- int n;
- printf("Introduza o tamanho do vetor: ");
- scanf("%d", &n);
- int *vect = (int *)malloc(sizeof(int) * n);
- for(int i=0; i<n; i++)
- {
- printf("Introduza o valor do vetor na posição %d: ", i);
- scanf("%d", &vect[i]);
- }
- int *v = InvFib(vect, n);
- printf("\nVector Fibonnaci Invertido :");
- for(int i=0; i<n; i++)
- printf("[%d]", v[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment