Difference between revisions of "Solução: Bits Trocados - OBI (Jandson Nunes)"

From AdonaiMedrado.Pro.Br
Jump to: navigation, search
(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;...)
(No difference)

Revision as of 12:29, 29 April 2009

#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++;
	}
}