All pastes #265204 Raw Edit

Miscellany

public cpp v1 · immutable
·published 2006-12-03 02:44 UTC
rendered paste body
#include <stdio.h>#include <iostream.h>#include <math.h>float x[5],y[5],k[3],l[3],m[3],sonuc[3];float det (float[],float[],float[]);float X,Y,X2,Y2,X2Y,XY,X3,X4,a,b,c;int main(){       printf (" x leri ve y leri x1,y1,x2,y2...  olarak sirasi ile girin\n");    for (int i=0;i<5;i++)    {        scanf("%f%f",&x[i],&y[i]);                X+=x[i];        Y+=y[i];        X2+=pow(x[i],2);        Y2+=pow(y[i],2);        X2Y+=(pow(x[i],2)*y[i]);        X3+=pow(x[i],3);        X4+=pow(x[i],4);        XY+=x[i]*y[i];        }      printf("\nX\t\tY\t\tX2\t\tY2\t\tXY\t\tX2Y\t\tX3\t\t\tX4\n\n");      for (int t=0;t<5;t++)      {          printf("%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n",x[t],y[t],pow(x[t],2),pow(y[t],2),x[t]*y[t],(pow(x[t],2)*y[t]),pow(x[t],3),pow(x[t],4));           }       k[0]=X4;       k[1]=X3;       k[2]=X2;       l[0]=X3;       l[1]=X2;       l[2]=X;        m[0]=X2;       m[1]=X;       m[2]=5;       sonuc[0]=X2Y;       sonuc[1]=XY;       sonuc[2]=Y;   a= det(sonuc,l,m)/det(k,l,m); // cramer yontemi ile a,b,c bulunur   b= det(k,sonuc,m)/det(k,l,m);   c= det(k,l,sonuc)/det(k,l,m);      printf(" \n\nf(x)= %fx^2+%fx+%f \n",a,b,c);      system("pause");   return 0;}                                         float det (float d1[],float d2[],float d3[])  {        float sonuc;         sonuc=d1[0]*(d2[1]*d3[2]-d2[2]*d3[1])-d2[0]*(d1[1]*d3[2]-d1[2]*d3[1])+d3[0]*(d1[1]*d2[2]-d1[2]*d2[1]);        return sonuc;        }