Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int vetor[4] = {0,0,0,0};
- int rec(int valor){
- if (valor == 0){
- return 0;
- } else if (valor >= 50){
- vetor[0]++;
- valor-=50;
- }else if (valor >= 10){
- vetor[1]++;
- valor-=10;
- }else if (valor >= 5){
- vetor[2]++;
- valor-=5;
- }else if (valor >= 1){
- vetor[3]++;
- valor-=1;
- }
- return rec(valor);
- }
- int main(){
- int entrada;
- do{
- scanf ("%d", &entrada);
- rec(entrada);
- if (entrada != 0){
- printf("%d %d %d %d", vetor[0], vetor[1], vetor[2], vetor[3]);
- vetor[0] = 0;
- vetor[1] = 0;
- vetor[2] = 0;
- vetor[3] = 0;
- }
- }while(entrada != 0);
- return 0;
- }
Add Comment
Please, Sign In to add comment