-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnayeli.cpp
More file actions
108 lines (99 loc) · 2.32 KB
/
nayeli.cpp
File metadata and controls
108 lines (99 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <iostream>
using namespace std;
float static fact(float numero);
float static pow(float numero,float potencia);
float cos(float x, int rep);
float sen(float x, int rep);
float logn(float x, int rep);
int main()
{
float numero=0.00, suma=0.00;
int limite;
/*
cout<<"Introduce el valor de x"<<"\t";
cin>>numero;
cout<<"¿Cuantas veces quieres correlo?"<<"\t";
cin>>limite;
cout<<cos(numero,limite)*/
cout << "Opcion 1 = Seno" << endl << "Opcion 2 = Coseno" << endl << "Opcion 3 = Logaritmo natural" << endl << "opcion 0= salir" << endl;
cout << "Introduce la opcion:" << "\t";
cin >> op;
while (op != 0)
{
switch (op)
{
case 1:
//seno
system("cls");
cout << "Introduce el valor de x" << "\t";
cin >> numero;
cout << "¿Cuantas veces quieres correlo?" << "\t";
cin >> limite;
cout << sen(numero, limite);
break;
case 2:
//Coseno
system("cls");
cout << "Introduce el valor de x" << "\t";
cin >> numero;
cout << "¿Cuantas veces quieres correlo?" << "\t";
cin >> limite;
cout << cos(numero, limite);
break;
case 3:
system("cls");
cout << "Introduce el valor de x" << "\t";
cin >> numero;
cout << "¿Cuantas veces quieres correlo?" << "\t";
cin >> limite;
cout << logn(numero, limite);
break;
default:
cout << "No es una opcion correcta";
break;
}
cout << endl << "Introduce la opcion:" << "\t";
cin >> op;
}
return 0;
}
float cos(float x, int rep){
float res = 0.00;
for(float i = 1.00; i <= rep; i++){
res+=(pow(x,(2*(i-1))) / fact(2*(i-1))) * pow(-1,i+1)
}
return res;
}
float sen(float x, int rep){
float res = 0.00;
for(float i = 1.00; i <= rep; i++){
res+=((pow(x,((2*i)-1))/fact((2*i) -1))) * (pow(-1,i-1))
}
return res;
}
float logn(float x, int rep){
float res = 0.00;
for(float i = 1.00; i <= rep; i++){
res+=(1/i)*pow(((x-1)/x),i)
}
return res;
}
float static fact(float numero)
{
float f=1.00;
for(int i=1;i<=numero;i++)
{
f*=i;
}
return f;
}
float static pow(float numero,float potencia)
{
float pot;
pot=1.00;
for(int i= 1;i<=potencia;i++)
{
pot*=numero;
}
return pot;
}