Advertisement
mantertius

rickyception.c

Nov 24th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.02 KB | None | 0 0
  1. //https://thehuxley.com/problem/1290
  2. #include <stdio.h>
  3.  
  4. static int count = 0;
  5. static int n,t;
  6. int contador()
  7. {
  8.     if (count == t)
  9.     {
  10.         return 1;
  11.     }
  12.     else
  13.     {
  14.         count++;
  15.         return 0;
  16.     }
  17. }
  18. int soma3 (int x)
  19. {
  20.     int resultado = (x + 3);
  21.     return resultado;
  22. }
  23. int divide5 (int x)
  24. {
  25.     int resultado = (x + (x%5));
  26.     return resultado;
  27. }
  28. int escolhedor(int numero)
  29. {
  30.     int result;
  31.    
  32.     if (count%2 == 0)
  33.     {
  34.         result = soma3(numero);
  35.         contador();
  36.         if (contador() == 1)
  37.         {
  38.             return result;  
  39.         }
  40.         escolhedor(result);
  41.     }
  42.     else if(count%2 != 0)
  43.     {
  44.         result = divide5(numero);
  45.         contador();
  46.         if (contador() == 1)
  47.         {
  48.             return result;  
  49.         }
  50.         escolhedor(result);
  51.     }
  52.    
  53.     return result;
  54. }
  55.  
  56.  
  57. int main()
  58. {
  59.     scanf("%d%d",&n,&t);
  60.     int resultado_final = escolhedor(n);
  61.     printf("%d\n", resultado_final);
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement