Difference between revisions of "Solução: Bits Trocados - OBI (Jandson Nunes)"
From AdonaiMedrado.Pro.Br
(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;...) |
|||
Line 5: | Line 5: | ||
int valor, cedulas[4] = {0}, teste = 1, i; | int valor, cedulas[4] = {0}, teste = 1, i; | ||
− | |||
while (valor){ | while (valor){ | ||
− | + | scanf("%d", &valor); | |
− | + | cedulas[0] = valor / 50; | |
− | + | valor = valor%50; | |
− | + | cedulas[1] = valor/10; | |
− | + | valor = valor%10; | |
− | + | cedulas[2] = valor/5; | |
− | + | valor = valor%5; | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
cedulas[3] = valor; | cedulas[3] = valor; | ||
valor = 0; | valor = 0; |
Revision as of 12:37, 29 April 2009
#include <stdio.h> int main () { int valor, cedulas[4] = {0}, teste = 1, i; while (valor){ scanf("%d", &valor); cedulas[0] = valor / 50; valor = valor%50; cedulas[1] = valor/10; valor = valor%10; cedulas[2] = valor/5; valor = 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++; } }