Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <stdio.h>
  2. #define DEBUG if(1)
  3.  
  4. void ler_array(int contador, int array[], double t, int max)
  5. {
  6.  
  7. if(contador == max) return;
  8.  
  9. else
  10. {
  11. scanf("%lf", &t);
  12. array[contador] = t;
  13. }
  14.  
  15. ler_array(contador+1, array, t, max);
  16. }
  17.  
  18. void imprimir_array(int contador, int array[], int k, int cont2, int max)
  19. {
  20. if(cont2 == max)
  21. {
  22. double win;
  23. win = k;
  24. printf("O tempo para o alinhamento dos planetas e %.1lf minutos", win);
  25. return;
  26. }
  27. if(k < array[contador])
  28. {
  29. k = array[contador];
  30. if(k % array[contador] == 0)
  31. {
  32. imprimir_array(contador+1, array, k, cont2+1, max);
  33. }
  34. else
  35. k+k;
  36. imprimir_array(contador+1, array, k, cont2+1, max);
  37. }
  38.  
  39.  
  40. }
  41.  
  42. int main()
  43. {
  44. int contador, k, netuno;
  45. scanf("%d\n", &netuno);
  46. int array[netuno];
  47. ler_array(0, array, 0, netuno);
  48. imprimir_array(0, array, 0, 0, netuno);
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement