Dev - C++ - matriz inversa no sale la impresion pero de los demas si sale

 
Vista:
sin imagen de perfil

matriz inversa no sale la impresion pero de los demas si sale

Publicado por Torrico (4 intervenciones) el 19/11/2021 16:30:11
#include<windows.h>
#include<iostream>
#include<math.h>
#include <stdio.h>
using namespace std;
COORD coord={0,0};
void gotoxy(int x,int y){
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void menu(){
cout<<"--------------------------------"<<endl;
cout<<"Menu de Opciones"<<endl;
cout<<"1.- matriz inversa"<<endl;
cout<<"2.- formula general"<<endl;
cout<<"3.- funcion "<<endl;
cout<<"4.-salir"<<endl;
}
float formula1(float a,float b,float c,float d){
float x1;
x1 = (-b+sqrt(d))/(2*a);
return x1;
}
float formula2(float a,float b,float c,float d){
float x2;
x2 = (-b-sqrt(d))/(2*a);
return x2;
}
float fun(float w,float y,float z){
float resu;
resu=sqrt(3*w*w*w*w+2*w*y*y*z+5*w*w*y)/(3+w*w+y*y+z*z);
return resu;
}

int main(){
int opcion;
short int i,j,k,n;
float a,b,c,r1,r2,d,x,w,y,z,R,A[n][n], I[n][n], aux, pivote;
system("color 02");
menu();
cout<<"Elige una de las opciones"<<endl;
cin>>opcion;
system("cls");
switch(opcion){
case 1:system("color 01");
cout<<"introduzca el numero de filas y columnas de la matriz nxn : "<<endl;
cin>>n;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
gotoxy(j*5,i+3);
cin>>A[i][j];
I[i][j]=0;
if(i==j){
I[i][j]=1;
}

}
}
for(i=0;i<n;i++){
pivote=A[i][i];
for(k=0;k<n;k++){
A[i][k]=A[i][k]/pivote;
I[i][k]=I[i][k]/pivote;
}
for(j=0;j<n;j++){
if(i!=j){
aux=A[j][i];
for(k=0;k<n;k++){
A[j][k]=A[j][k]-aux*A[i][k];
I[j][k]=I[j][k]-aux*I[i][k];
}
}
}
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
gotoxy(j*5,i+10);
cout<<"|"<<A[i][j]<<"|";

gotoxy(50+j*10,i+10);
cout<<"|"<<I[i][j]<<"|";
}
}

break;
case 2:system("color 03");
cout<<"ingrese el valor de a"<<endl;
cin>>a;
while (a == 0) {
cout<<"ingrese el valor de a"<<endl;
cin>>a;
}
cout<<"ingrese el valor de b"<<endl;
cin>>b;
cout<<"ingrese el valor de c"<<endl;
cin>>c;
d = b*b-4*a*c;
if (d > 0) {
r1=formula1(a,b,c,d);
r2=formula2(a,b,c,d);
cout<<"x1 es = "<<r1<<endl;
cout<<"x2 es = "<<r2<<endl;
}
else
if (d == 0) {
x = (-b)/(2*a);
cout<<"el valor de x es = "<<x<<endl;
}
else
cout<<"la ecuacion no tiene solucion"<<endl;
break;
case 3:system("color 04");
cout<<"ingrese el valor de x, y, z"<<endl;
cin>>w>>y>>z;
R=fun(w,y,z);
cout<<"el resultado de la funcion es = "<<R<<endl;



break;
case 4:cout<<"gracias por usar el programa"<<endl;
break;
default:cout<<"Opcion no valida"<<endl;
}
return 0;
}
1
='editor_code'>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder