Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdbool.h>
  5. #include <math.h>
  6.  
  7. const double IZP_E = 2.7182818284590452354;
  8.  
  9.  
  10. double absol(double x, double y){
  11.     return(x-y<0)?y-x: x-y;
  12. }
  13.  
  14.  
  15. int main()
  16. {
  17.     double vstup=0;
  18.     double sigdig=0.0001;
  19.     double s=1;
  20.     double pom=0,lnx=0;
  21.     printf("Zadejte x pro lnx:");
  22.     scanf("%lf",&vstup);
  23.  
  24.     while(vstup<-1 || vstup>1){
  25.     vstup=vstup/IZP_E;
  26.     pom++;
  27.     }
  28.  
  29.     double starylnx=0;
  30.     double dalsilnx=0;
  31.     do{
  32.         starylnx=dalsilnx;
  33.         dalsilnx=(((pow(-1,s+1))*(pow((vstup-1),s)))/s);
  34.         lnx=lnx+dalsilnx;
  35.         s++;
  36.     }while((fabs(starylnx+dalsilnx))>=sigdig);
  37.     lnx=lnx+pom;
  38.  
  39.     printf("%.10e\n", lnx);
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement