11.07.2015 Views

Lista 03a - DCC/UFMG

Lista 03a - DCC/UFMG

Lista 03a - DCC/UFMG

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

52) Implementar um algoritmo em PORTUGOL para calcular o sen(X). O valor de Xdeverá ser digitado em graus. O valor do seno de X será calculado pela soma dos 15primeiros termos da série a seguir:3xsen( X ) = x −3!+5x5!7x−7!9x+9!11x− + ...11!algoritmo L3P052;varinteiro: I, J, FAT;real: X, SEN;inícioSEN ← 0;leia(X);para I de 1 até 15 façaFAT ← 1;para J de 2 até 2*I – 1 façaFAT ← FAT * J;fim-parase ( I mod 2 = 0 ) entãoSEN ← SEN – ( X ** ( 2 * I – 1 ) ) / FAT; { termo par }senãoSEN ← SEN + ( X ** ( 2 * I – 1 ) ) / FAT; { termo ímpar }fim-sefim-paraimprima("SEN(",X,") = ",SEN);fimalgoritmo L3P052B;varinteiro: I, FAT;real: X, SEN;inícioFAT ← 1;SEN ← 0;leia(X);para I de 1 até 15 façase (X ≠ 0) entãose ( I mod 2 = 0 )então SEN ← SEN – ( X ** ( 2 * I – 1 ) ) / FAT; { termo par }senão SEN ← SEN + ( X ** ( 2 * I – 1 ) ) / FAT; { termo ímpar }fim-sefim-seFAT ← FAT * ( 2 * I ) * ( 2 * I + 1 );fim-paraimprima("SEN(",X,") = ",SEN);fim<strong>UFMG</strong> – ICEx – <strong>DCC</strong> – Programação de Computadores – 2º. Sem 2005 – David Menoti 54

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!