Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #pragma once
  2. #ifndef __MEU_H_INCLUDED__
  3. #define __MEU_H_INCLUDED__
  4.  
  5. #include <stdlib.h>
  6. #include <iostream>
  7. #include <iomanip>
  8. #include <string>
  9. #include <vector>
  10.  
  11.  
  12.  
  13. void imprime(std::vector<int>& v);
  14. void fibonacci(int x, int y, std::vector<int> fi, int numeroElementos);
  15.  
  16. #endif
  17.  
  18. #include "stdafx.h"
  19. #include "meu.h"
  20.  
  21.  
  22. using std::cout;
  23. using std::endl;
  24.  
  25.  
  26. void imprime(std::vector<int>& v)
  27. {
  28.  
  29. for(int x = 0; x < v.size(); x++)
  30. cout << v[x];
  31. }
  32.  
  33. void fibonacci(int x, int y, std::vector<int> fi, int numeroElementos)
  34. {
  35.  
  36. int z = 0;
  37.  
  38. for (int b = 0; b <= numeroElementos; b++)
  39. {
  40. z = x + y;
  41. fi.push_back(z);
  42. x = y;
  43. y = z;
  44. }
  45. }
  46.  
  47. #include "stdafx.h"
  48. #include "meu.h"
  49.  
  50. int main()
  51. {
  52. int valor1 = 0;
  53. int valor2 = 0;
  54. int NumeroElementos = 0;
  55. std::vector<int> numeros;
  56.  
  57. while (std::cin >> valor1 >> valor2 >> NumeroElementos) {
  58. fibonacci(valor1, valor2, numeros, NumeroElementos);
  59. imprime(numeros);
  60. }
  61.  
  62.  
  63.  
  64.  
  65.  
  66. system("pause");
  67.  
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement