/* ATENÇÃO ESTE PROGRAMA ESTÁ EM ARQUIVO TEXTO (.txt) MUDAR PARA .c PARA COMPILAR E RODAR */ /* centavos.c */ /* Teorema: Qualquer quantia N superior a 7 centavos pode ser paga exatamente */ /* apenas com moedas de 3 centavos e 5 centavos. */ #include struct qtd{ int p; int q; }; typedef struct qtd moedas; // Prototypes moedas repr ( int ); // Principal int main(void) { moedas resp; int num; printf(" Digite a quantia: "); scanf("%d",&num); resp = repr(num); printf("%d moeda(s) de 5 e %d moeda(s) de 3.\n",resp.p, resp.q); return 1; } moedas repr(int n) { moedas temp; if (n==8) { temp.p=1; temp.q=1; return temp; } if (n==9) { temp.p=0; temp.q=3; return temp; } if (n==10) { temp.p=2; temp.q=0; return temp; } temp=repr(n-3); (temp.q)++; return temp; }