Lista exercicios algoritmo, programaçao
Por: NTTS • 11/6/2015 • Trabalho acadêmico • 482 Palavras (2 Páginas) • 580 Visualizações
// 11.2
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;
double AWC(int n){
int i, c = 1.0;
double s = 0.0;
for(i = 1.0; i <= n; i++){
s = s + i/(2.0*i-1.0)*c;
c = -c;
}
return s;
}
int main(int argc, char** argv){
int n;
double s;
cout << "Digite o numero de parcelas: "; cin >> n;
s = AWC(n);
cout << "Soma = " << s << endl;
system("pause");
return 0;
}
// 11.5
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
using namespace std;
double AWC(int n){
int i, c = 1.0; double s = 0.0;
for(i = 1.0; i <= n; i++){
s = s + 4/(2.0*i - 1.0)*c;
c = -c;
}
return s;
}
int main(int argc, char** argv) {
int n; double s;
cout << "Digite o numero de parcelas: "; cin >> n;
s = AWC(n);
cout << "A soma eh = " << s << endl;
system("pause");
return 0;
}
// 11.6
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;
double AWC(int n){
int i, c = 1.0;
double p, S = 0.0;
for(i = 1.0; i <= n; i++){
S = S + 1/pow(2.0*i-1.0, 3.0)*c;
c = -c;
}
p=pow(S*32.0, (1.0/3.0));
return p;
}
int main(int argc, char** argv){
int n;
double p;
cout << "Digite o numero de parcelas: "; cin >> n;
p = AWC(n);
cout << "Soma = " << p << endl;
system("pause");
return 0;
}
// 11.11
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
using namespace std;
double rad(double x){
return x*M_PI/180.0;
}
long double fat(int x){
int j;
long double f = 1.0;
for(j = 1.0; j <= x; j++)
f = f*j;
return f;
}
double cosseno(double x, int n){
int i, c = -1.0;
double s = 1.0;
x = rad(x);
for(i = 0.0; i <= n-1.0; i++){
s = s + pow(x, (2.0*i))/fat(2.0*i)*c;
c = -c;
}
return s;
}
int main(int argc, char** argv) {
int n; double s, x;
cout << "Digite o valor do angulo em graus: "; cin >> x;
cout << "Digite o numero de parcelas: "; cin >> n;
s = cosseno(x, n);
cout << "Cos(" << x << "): " << s << endl;
system("pause");
...