Solução: Bits Trocados - OBI (Jandson Nunes)

From AdonaiMedrado.Pro.Br
Revision as of 12:29, 29 April 2009 by 200.17.147.2 (Talk) (New page: <code lang="c"> #include <stdio.h> int main () { int valor, cedulas[4] = {0}, teste = 1, i; scanf("%d", &valor); while (valor){ while (valor >= 50){ cedulas[0]++; valor -= 50;...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
#include <stdio.h>
 
int main () {
	int valor, cedulas[4] = {0}, teste = 1, i;
 
	scanf("%d", &valor);
	while (valor){
		while (valor >= 50){
			cedulas[0]++;
			valor -= 50;
		}
		while (valor >= 10){
			cedulas[1]++;
			valor -= 10;
		}
		while (valor >= 5){
			cedulas[2]++;
			valor -= 5;
		}
		cedulas[3] = valor;
		valor = 0;
		printf("Teste %d\n", teste);
		for (i = 0; i < 4; i++){
			printf("%d ", cedulas[i]);
			cedulas[i] = 0;
		}
		printf("\n\n");
		scanf("%d", &valor);
		teste++;
	}
}