Tercer Grado

Codigo Fuente C++

#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <ctime>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
#include <math.h>
# define A 3
# define B 0
# define C -300
float x,y,z,u,a[10],b[10];
float c[10],d[10],e[10],det;
void   tresincognitas(void)
{
string polinomios1[20][20]={{"x+2y+6z=8"  },{"x-2y-x=-6" },{"3x-6x²=2x²-5x"},{"x+y-x=7"   },{"2x-4y+6z=18"   },{"2x-4y+6z=18"},{"(2x+y-z=8"  },{"x-2y+z=5"   },{"6x+3y+2z=12" },{"x-2y+3z=9 "  },{"2x-5y+5z=17"},{"x-2y+z=2"   },{"x+y+z=2"  },{"x+y+z=11"  }};
string polinomios2[20][20]={{"x+2y+7z=24" },{"-3x+1y-1=2"},{"-x²+4x-7=0"   },{"4x-y+5z=4" },{"4x+5y+6z=24"  },{"4x+5y+6=24²"},{"3x-y+2z=-11"},{"-2x+4y+0=-8"},{"9x-y+4z=37"  },{"-x+3y+0=-4"  },{"x-2y+3z=9"  },{"-3x+y-z=-6" },{"3x+y-z=18"},{"2x-y+z=5"  }};
string polinomios3[20][20]={{"3x+2y+4z=34"},{"2x+6y+4=2" },{"x²-x=0"       },{"2x-2y-3z=0"},{"3x+y-2z=4"},{"3x+y-2z=4"  },{"-2x+y+z=-3" },{"3x+y-z=4"   },{"10x+5y+3z=21"},{" 2x-5y+5z=17"},{"-x+3y+0=-4" },{"2x+6y-4z=-6"},{"x-y+z=0"  },{"3x+2y-z=24"}};

 a[1]=2;
 b[1]=4;
 c[1]=6;   //Polinomio 1
 d[1]=18;
//----------------------------------------------
 a[2]=4;
 b[2]=5;  //Polinomio 2
 c[2]=6;
 d[2]=24;
//----------------------------------------------
 a[3]=3;
 b[3]=1;   //Polinomio 3
 c[3]=-2;
 d[3]=4;


int i,n,jj,j,n3,k,nn;
srand(time(NULL));
n=(0+rand()%(14+0));
cout<<"\tSITEMAS DE TRES ECUACIONES \tEjemplos:\t"<<polinomios1[n][jj];



nn=(1+rand()%(2+0));
cout<<"\n\t\t                 \t\t\t"<<polinomios2[n][jj];
n3=(1+rand()%(9+1));
cout<<"\n\t\t\t\t\t\t\t"<<polinomios3[n][jj];
cout<<"\n";

 cout<<"\t _____________________________\n";
 cout<<"\t|                                    \n";
 cout<<"\t|  "<<a[1]<<"x"<<"\t"<<b[1]<<"y\t"<<c[1]<<"z"<<"\t"<<d[1]<<"   \n";
 cout<<"\t|  "<<a[2]<<"x"<<"\t"<<b[2]<<"y\t"<<c[2]<<"z"<<"\t"<<d[2]<<"   \n";
 cout<<"\t|  "<<a[3]<<"x"<<"\t"<<b[3]<<"y\t"<<c[3]<<"z"<<"\t"<<d[3]<<"   \n";
 cout<<"\t|_____________________________\n";

 det=(a[1]*b[2]*c[3])+(b[1]*c[2]*a[3])+(c[1]*a[2]*b[3])-(a[3]*b[2]*c[1])-(b[3]*c[2]*a[1])-(c[3]*a[2]*b[1]);

 if(det==0)
 printf("\t\t\tLas ecuaciones son incompatibles");
 else
  {/*inicio de la funcion sino*/
    x=((d[1]*b[2]*c[3])+(b[1]*c[2]*d[3])+(c[1]*d[2]*b[3])-(d[3]*b[2]*c[1])-(b[3]*c[2]*d[1])-(c[3]*d[2]*b[1]))/det;

    y=((a[1]*d[2]*c[3])+(d[1]*c[2]*a[3])+(c[1]*a[2]*d[3])-(a[3]*d[2]*c[1])-(d[3]*c[2]*a[1])-(c[3]*a[2]*d[1]))/det;
    z=((a[1]*b[2]*d[3])+(b[1]*d[2]*a[3])+(d[1]*a[2]*b[3])-(a[3]*b[2]*d[1])-(b[3]*d[2]*a[1])-(d[3]*a[2]*b[1]))/det;

   printf("\n\t\t\tLa  Solucion es...");   
   printf("\n\t\t\t         x es:%g",x);
   printf("\n\t\t\t         y es:%g",y);
   printf("\n\t\t\t         z es:%g",z);
   printf("\n\n\nDocente:Nestor Calderon Hernandez\t\t\t");
   printf("\n\n\n");
}/*fin de la funcion sino*/

//getch();
}

int main()
{
tresincognitas();
     
}





No hay comentarios:

Publicar un comentario