Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdbool.h>
  5.  
  6. const double IZP_E = 2.7182818284590452354;        // e
  7. const double IZP_PI = 3.14159265358979323846;      // pi
  8. const double IZP_2PI = 6.28318530717958647692;     // 2*pi
  9. const double IZP_PI_2 = 1.57079632679489661923;    // pi/2
  10. const double IZP_PI_4 = 0.78539816339744830962;    // pi/4
  11.  
  12. double sigdig=0.001;
  13. double vstup=2.71;
  14. double sih=0;
  15. double coh=0;
  16. float tnh=0;
  17. double starycoh=0;
  18. double dalsicoh=0;
  19. double starysih=0;
  20. double dalsisih=0;
  21. double s=0;
  22. double exponent;
  23. double moc;
  24. double f=1;
  25. double n;
  26.  
  27.  
  28. double mocnina(double vstup, double s){
  29.     moc=1;
  30.     for(n=0; n<s; n++){
  31.     moc=moc*vstup;
  32.     }
  33.     return(moc);
  34. }
  35.  
  36. double absol(double x, double y){
  37.     return(x-y<0)?y-x: x-y;
  38. }
  39.  
  40. double fakt(double z){
  41.     for(; n>0; n--){
  42.         f=f*n;
  43.     }
  44.     return(f);
  45. }
  46.  
  47. double sinush(double vstup){
  48.     s=1;
  49.     starysih=(vstup/(fakt(s)));
  50.     do{
  51.         s=s+2;
  52.         dalsisih=((mocnina(vstup, s))/(fakt(s)));
  53.         sih=starysih+dalsisih;
  54.     }while((absol(starysih, sih))<sigdig);
  55.     return(sih);
  56. }
  57.  
  58. double cosinush(double vstup){
  59.     s=0;
  60.     starycoh=1;
  61.     do{
  62.         s=s+2;
  63.         starycoh=coh;
  64.         dalsicoh=((mocnina(vstup, s))/(fakt(s)));
  65.         coh=starycoh+dalsicoh;
  66.     }while((starycoh-coh)<sigdig);
  67.     return(coh);
  68. }
  69.  
  70. int hypertan(){
  71.         sinush(vstup);
  72.         cosinush(vstup);
  73.         tnh=sih/coh;
  74.     printf("%.10e\n", tnh);
  75. return(0);
  76. }
  77.  
  78. int main()
  79. {
  80.     hypertan();
  81.     return(0);
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement