c_cpp (Uri Judge)Problema 2033 C ++ - 接受

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp (Uri Judge)Problema 2033 C ++ - 接受相关的知识,希望对你有一定的参考价值。

/*  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;
}

以上是关于c_cpp (Uri Judge)Problema 2033 C ++ - 接受的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0013&lang=jp

c_cpp http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0013&lang=jp

c_cpp http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=jp

c_cpp a thiefhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id = 0042サンプルは通るのですがWAになりますよかったら间

c_cpp 比赛Uri - Monopolio

c_cpp Uri 1728 - (已接受)