Guest User

Untitled

a guest
Jan 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3.  
  4. int vetor[4] = {0,0,0,0};
  5.  
  6. int rec(int valor){
  7.     if (valor == 0){
  8.         return 0;
  9.     } else if (valor >= 50){
  10.         vetor[0]++;
  11.         valor-=50;
  12.     }else if (valor >= 10){
  13.         vetor[1]++;
  14.         valor-=10;
  15.     }else if (valor >= 5){
  16.         vetor[2]++;
  17.         valor-=5;
  18.     }else if (valor >= 1){
  19.         vetor[3]++;
  20.         valor-=1;
  21.     }
  22.  
  23.     return rec(valor);
  24. }
  25.  
  26. int main(){
  27.  
  28.     int entrada;
  29.  
  30.     do{
  31.         scanf ("%d", &entrada);
  32.         rec(entrada);
  33.  
  34.         if (entrada != 0){
  35.             printf("%d %d %d %d", vetor[0], vetor[1], vetor[2], vetor[3]);
  36.             vetor[0] = 0;
  37.             vetor[1] = 0;
  38.             vetor[2] = 0;
  39.             vetor[3] = 0;
  40.         }
  41.  
  42.     }while(entrada != 0);
  43.  
  44.     return 0;
  45. }
Add Comment
Please, Sign In to add comment