Created
June 22, 2014 22:08
-
-
Save joaorafaelm/0778e0fecdc54be1e7b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int calculateValor(int valor, int sub); | |
int main() | |
{ | |
int valor; | |
int sub[] = {100, 50, 20, 10, 2, 1}; | |
puts("DIGITE UM VALOR:"); | |
if (scanf("%i", &valor) == 1) { | |
for (int i = 0; i < sizeof(sub); ++i){ | |
valor = calculateValor(valor, sub[i]); | |
} | |
}else puts("Número Inválido!"); | |
} | |
int calculateValor(int valor, int sub){ | |
int count; | |
count = 0; | |
while (valor >= sub) | |
{ | |
valor = valor - sub; | |
count = count + 1; | |
} | |
printf("Notas de %i : %i\n", sub, count); | |
if(valor == 0) exit(0); else return valor; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment