Skip to content

Instantly share code, notes, and snippets.

@antonio-abrantes
Created June 28, 2016 01:10
Show Gist options
  • Save antonio-abrantes/51c80da9676518ede3172e1e483c6e31 to your computer and use it in GitHub Desktop.
Save antonio-abrantes/51c80da9676518ede3172e1e483c6e31 to your computer and use it in GitHub Desktop.
Uri 2033 - (Accepted)
#include <stdio.h>
#include <math.h>
int main()
{
int tempo;
double capital, juroSimples, juroCompos, diferenca, expo;
double txJuros;
while(scanf("%lf", &capital) != EOF)
{
scanf("%lf", &txJuros);
scanf("%d", &tempo);
juroSimples = capital * txJuros * tempo;
expo = pow(1 + txJuros, tempo);
juroCompos = (capital * expo) - capital;
if(juroSimples >= juroCompos)
diferenca = juroSimples - juroCompos;
else
diferenca = juroCompos - juroSimples;
printf("DIFERENCA DE VALOR = %.2lf\n", diferenca);
printf("JUROS SIMPLES = %.2lf\n", juroSimples);
printf("JUROS COMPOSTO = %.2lf\n", juroCompos);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment