Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- #include <math.h>
- #define NRMAX 10
- void reghip (int m, float x[NRMAX], float y[NRMAX], float *a, float *b)
- {
- float sx,sy,sxx,sxy;
- int i;
- sx=0; sy=0; sxx=0; sxy=0;
- for (i=0;i<m;i++)
- { sx=sx+x[i];
- sy=sy+1/y[i];
- sxy=sxy+x[i]/y[i];
- sxx=sxx+x[i]*x[i];
- }
- *a=(m*sxy-sx*sy)/(m*sxx-sx*sx);
- *b=(sxx*sy-sx*sxy)/(m*sxx-sx*sx);
- }
- int main (void)
- {
- int i,m;
- float a,b;
- float X[NRMAX],Y[NRMAX];
- printf("REGRESIA HIPERBOLICA");
- printf("\nIntroduceti numarul experientelor:");
- scanf("%d",&m);
- printf("\nIntroduceti abscisele si ordonatele functiei:");
- for (i=0;i<m;i++)
- {
- printf("\nX[%d]=",i);
- scanf("%f",&X[i]);
- printf("Y[%d]=",i);
- scanf("%f",&Y[i]);
- }
- reghip(m,X,Y,&a,&b);
- printf("Rezultatul regresiei hiperbolice este: a=%f; b=%f",a,b);
- getch();
- return 1;
- }
Add Comment
Please, Sign In to add comment