Last active
June 28, 2016 01:48
-
-
Save antonio-abrantes/656fc9019ba091a15111348da4b427f9 to your computer and use it in GitHub Desktop.
(Uri Judge) Problema 2033 C++ - Accepted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Juros Sobre o Empréstimo - Problemas nº 2033 - Matematica | |
https://www.urionlinejudge.com.br/judge/pt/problems/view/2033 | |
Problema com Accepted */ | |
#include <iostream> | |
#include <iomanip> | |
#include <stdio.h> | |
#include <cmath> | |
using namespace std; | |
int main(){ | |
int tempo; | |
double capital, juroSimples, juroCompos, diferenca, expo, 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){ // O if/else pode ser substituido por um fabs(juroSimples - juroCompos) | |
diferenca = juroSimples - juroCompos; | |
cout << fixed; | |
cout << "DIFERENCA DE VALOR = " << setprecision(2) << diferenca<< endl; | |
}else{ | |
diferenca = juroCompos - juroSimples; | |
cout << fixed; | |
cout << "DIFERENCA DE VALOR = " << setprecision(2) << diferenca << endl; | |
} | |
cout << fixed; | |
cout << "JUROS SIMPLES = " << setprecision(2) << juroSimples << endl; | |
cout << "JUROS COMPOSTO = " << setprecision(2) << juroCompos << endl; | |
} //A solucao so ira passar sem o duplo "\n" no final | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment