online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, COBOL, HTML, CSS, JS Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ //Matrices /* Un programa que pida al usuario los datos de una matriz de 3×3, y calcule y muestre su matriz inversa. */ #include<iostream> #include<locale.h> #include<conio.h> int main(){ setlocale(LC_CTYPE, "Spanish"); int opt = 0; double mz[3][3] = {}; double det = 0, det1 = 0, det2 = 0, rta = 0, a = 0, b= 0, c= 0, d= 0, e= 0, f= 0, g= 0, h= 0, k= 0; system("cls"); std::cout<<"INVERSA DE MATRIZ 3 X 3"<<std::endl<<std::endl<<"Ubicación de datos en la matriz"<<std::endl<<"|[0][0] [0][1] [0][2]|"<<std::endl<<"|[1][0] [1][1] [1][2]|"<<std::endl<<"|[2][0] [2][1] [2][2]|"<<std::endl<<std::endl; std::cout<<"Ingreso de datos de su matriz 3 x 3"<<std::endl; for(int i = 0; i<=2; i++){ //Ingreso de datos. for(int j = 0; j<=2; j++){ std::cout<<"["<<i<<"] ["<<j<<"] = "; std::cin>>mz[i][j]; } std::cout<<std::endl; } //Presentación de la matriz. std::cout<<"-Matriz"<<std::endl; for(int i = 0; i<=2; i++){ std::cout<<"| "; for(int j = 0; j<=2; j++){ std::cout<<mz[i][j]<<" | "; } std::cout<<std::endl; } //Calcular la determinante. det = (mz[0][0])*(((mz[1][1])*(mz[2][2]))-((mz[1][2])*(mz[2][1]))); det1 = (mz[0][1])*(((mz[0][1])*(mz[2][2]))-((mz[1][2])*(mz[2][0]))); det2 = (mz[0][2])*(((mz[0][1])*(mz[2][1]))-((mz[1][1])*(mz[2][0]))); rta = det - (det1) + (det2); std::cout<<std::endl<<"-La determinante de su matriz = "<<rta<<std::endl; //Calcular la adjunta. a = +(((mz[1][1])*(mz[2][2]))-((mz[1][2])*(mz[2][1]))); b = -(((mz[1][0])*(mz[2][2]))-((mz[1][2])*(mz[2][0]))); c = +(((mz[1][0])*(mz[2][1]))-((mz[1][1])*(mz[2][0]))); d = -(((mz[0][1])*(mz[2][2]))-((mz[0][2])*(mz[2][1]))); e = +(((mz[0][0])*(mz[2][2]))-((mz[0][2])*(mz[2][0]))); f = -(((mz[0][0])*(mz[2][1]))-((mz[0][1])*(mz[2][0]))); g = +(((mz[0][1])*(mz[1][2]))-((mz[0][2])*(mz[1][1]))); h = -(((mz[0][0])*(mz[1][2]))-((mz[0][2])*(mz[1][0]))); k = +(((mz[0][0])*(mz[1][1]))-((mz[0][1])*(mz[1][0]))); double mz1[3][3] = {{a, b, c}, {d, e, f}, {g, h, k}}; std::cout<<std::endl<<"-Matriz adjunta 3 x 3"<<std::endl; for(int i = 0; i<=2; i++){ std::cout<<" | "; for(int j = 0; j<=2; j++){ std::cout<<mz1[j][i]<<" | "; } std::cout<<std::endl; } std::cout<<std::endl<<"-Matriz inversa 3 x 3"<<std::endl; for(int i = 0; i<=2; i++){ //Presentación de la matriz inversa. std::cout<<"| "; for(int j = 0; j<=2; j++){ std::cout<<((mz1[j][i])/rta)<<" | "; } std::cout<<std::endl; } //Ciclo DO WHILE para permitir al usario volver a inicio o salir. do{ std::cout<<std::endl<<"Volver a ingresar matriz[1] // Salir del programa[2]"<<std::endl<<"Opción = "; std::cin>>opt; if(opt == 1){ std::cout<<std::endl; return main(); } else if(opt > 2 || opt <= 0){ // Mensaje de error si no elige el 1 o el 2 como se le indica. std::cout<<"-----ERROR = Solo puede elegir el 1 o el 2-----"<<std::endl; } else{ std::cout<<std::endl<<"Gracias por usar este programa :D"; getch(); return 0; } }while(opt >= 3 || opt<=0); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue