Magentax

Cuad Gaus

Jan 19th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. //CuadGaus
  2.  
  3. #include <stdio.h>
  4. #include <conio.h>
  5. #include <math.h>
  6. float I_Gauss(float,float,int);
  7. float f(float);
  8. void main(void)
  9. {
  10.    clrscr();
  11.    float ls,ld;
  12.    int n=3;
  13.  
  14.    printf("\nIntroduceti ls : ");
  15.    scanf("%f",&ls);
  16.    printf("\nIntroduceti ld : ");
  17.    scanf("%f",&ld);
  18.  
  19.    printf("\nSolutia este = %f",I_Gauss(ls,ld,n));
  20.    getch();
  21. }
  22. float I_Gauss(float ls,float ld,int n)
  23. {
  24.    float sum;
  25.    int i;
  26.    float A[3]={5./9,8./9,5./9};
  27.    float U[3]={0.7745966692,0,-0.7745966692};
  28.    sum=0;
  29.    for(i=0;i<n;i++) // sunt >n< treceri
  30.    sum=sum+0.5*A[i]*(ld-ls)*f(0.5*(ld-ls)*U[i]+0.5*(ls+ld));
  31.    return sum;
  32. }
  33. float f(float x)
  34. {
  35.   return 2*x;
  36.   return exp(x);
  37. }
Add Comment
Please, Sign In to add comment