document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include <iostream>
  2. #include <math.h>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. long double seno(long double x,int y);
  7. long double coseno(long double x,int y);
  8. long double senoh(long double x,int y);
  9. long double cosenoh(long double x,int y);
  10. long long int factorial(int b);
  11. int i,j;
  12. main (){
  13.     double x,y;
  14.     int opc;
  15.    
  16.     cout<<"Ingrese el valor de z: "<<endl;
  17.     cin>>x;
  18.     cout<<"Ingrese cuantos terminos desea en la serie (a)\\n Recomandado usar un valor menor a 10: "<<endl;
  19.     cin>>y;
  20.     system("cls");
  21.     cout<<"1. Seno("<<x<<")\\n2. Coseno("<<x<<")\\n3. Senoh("<<x<<")\\n4. Cosenoh("<<x<<")\\nIngrese una Opcion: "<<endl;
  22.     cin>>opc;
  23.     cout<<fixed<<setprecision(7);
  24.     switch (opc){
  25.         case 1:
  26.             cout<<"seno = "<<seno(x,y)<<endl;
  27.         break;
  28.        
  29.         case 2:
  30.             cout<<"coseno = "<<coseno(x,y)<<endl;
  31.         break;
  32.        
  33.         case 3:
  34.             cout<<"senoh = "<<senoh(x,y)<<endl;
  35.         break;
  36.        
  37.         case 4:
  38.             cout<<"cosenoh = "<<cosenoh(x,y)<<endl;
  39.         break;
  40.        
  41.     }
  42.    
  43.    
  44.    
  45. }
  46.  
  47. long double seno (long double x, int y){
  48.     double acum=0;
  49.     for (i=0;i<=(y+1);i++){
  50.         acum=acum+pow(-1,i)*(pow(x,(2*i+1))/factorial(2*i+1));
  51.        
  52.     }
  53.     return acum;
  54.    
  55. }
  56.  
  57. long double coseno(long double x,int y){
  58.     double acum=0;
  59.     for (i=0;i<=(y+1);i++){
  60.         acum=acum+pow(-1,i)*(pow(x,(2*i))/factorial(2*i));
  61.        
  62.     }
  63.     return acum;
  64. }
  65. long double senoh(long double x,int y){
  66.     double acum=0;
  67.     for (i=0;i<=(y+1);i++){
  68.         acum=acum+(pow(x,(2*i+1))/factorial(2*i+1));
  69.        
  70.     }
  71.     return acum;
  72. }
  73.  
  74. long double cosenoh(long double x,int y){
  75.     double acum=0;
  76.     for (i=0;i<=(y+1);i++){
  77.         acum=acum+(pow(x,(2*i))/factorial(2*i));
  78.        
  79.     }
  80.     return acum;
  81. }
  82.  
  83. long long int factorial(int b){
  84.     long long int acum2=1;
  85.     for (j=0;j<=b;j++){
  86.         if (j==0){
  87.             acum2=1;
  88.         }else {
  89.             acum2=acum2*j;
  90.         }
  91.     }
  92.     return acum2;
  93.    
  94. }
');