Facebook
From a, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 186
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5.  
  6. int main(int argc, char *argv[]) {
  7.        
  8.        
  9.         double y,x,xd,a,b,i,sr,sum,maks,licznik=1,eps=0.00001;
  10.        
  11.         printf("Podaj xp\n");
  12.         scanf("%lf",&a);
  13.         printf("Podaj xk\n");
  14.         scanf("%lf",&b);
  15.         printf("Podaj xd\n");  
  16.         scanf("%lf",&xd);
  17.         if(xd<0)
  18.         {
  19.                 printf("xd musi byc wieksze od 0\n");
  20.         }else
  21.         {
  22.        
  23. x=a;
  24. if(x<0-eps)
  25.         {
  26.                 y=pow(x,3)+(1.0/x);
  27.         }else
  28.         {
  29.                 if(x>0-eps && x<0+eps)
  30.                 {
  31.                 y=3*(sqrt(2));
  32.                 }else
  33.                 {
  34.                         y=pow(sin(sqrt(x)),1.0/3.0);
  35.                 }
  36.         }
  37. printf("Y=%lf\n",y);
  38. maks=y;
  39. sum=sum+y;
  40.  
  41. for(i=a+xd;i<=b;i=i+xd)
  42. {
  43.         x=i;
  44.         if(x<0-eps)
  45.         {
  46.                 y=pow(x,3)+(1.0/x);
  47.         }else
  48.                 {
  49.                 if(x>0-eps && x<0+eps)
  50.                 {
  51.                 y=3*(sqrt(2));
  52.                 }else
  53.                 {
  54.                         y=pow(sin(sqrt(x)),(1.0)/3);
  55.                 }
  56.         }
  57.         printf("Y=%lf\n",y);
  58.         licznik++;
  59.         sum=sum+y;
  60.         if(y>maks)
  61.         {
  62.                 maks=y;
  63.         }
  64.  
  65. }
  66. sr=sum/licznik;
  67. printf("Srednia:%lf\n",sr);
  68. printf("Maks:%lf",maks);
  69. }
  70.  
  71.        
  72.        
  73.        
  74.         return 0;
  75. }