程序在运行时失败 [英] Program Fails in Runtime

查看:77
本文介绍了程序在运行时失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编译这段代码时,我得到0错误和一些警告(31),但是它允许我输入第一个矩阵的尺寸,提示用户输入第二个矩阵的大小,但立即关闭,可以...

When i compiles this code i get 0 errors and some warnings (31) however it allows me to enter the dimensions of the first matrix prompt user for size of second matrix but closes immediately, can...

void main()
{
int x,y,i,j;
  int cols;
   int rows;
    char ch;
  do
  {




   .....
      cout<<"\n*********************************************************"<<endl;
      cout<<"\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl;
      cout<<"\n*********************************************************"<<endl;


      cout<<"\nTHIS ASSIGNMENT IS TO COVER THE FOLLOWING: "<<endl;
      cout<<"\n                         > Find and displaying Determinant"<<endl;
      cout<<"\n                         > Find and displaying the Inverse"<<endl;
      cout<<"\n                           matrix"<<endl;
      cout<<"\n                         > Carrying out row transformation"<<endl;
      cout<<"\n                         > Addition & Subtraction"<<endl;
      cout<<"\n                         > Multiplicationn & division"<<endl;
      cout<<"\n"<<endl;
    cout<<"\n1.Add matrices\n2.Subtract matrices\n3.Multiplymatrices\n4.Find determinant\n5.Find INverse"<<endl;
    cout<<"Select any one above , then hit ENTER"<<endl;
    cin>>x;
    if(x==1)
    {cout<<"enter the dimension of matrix A:";
    cin>>rows>>cols;
    Matrix A ;//= Matrix(rows, cols);
    cout<<"enter the elements of matrix A:";
    for (int r = 0; r < rows; r++)
     { for (int c = 0; c < cols; c++)
       {
        cin>>A(r,c);
       }
     }
    cout<<"enter the dimension of matrix B:";
    Matrix B = Matrix(cols, rows);
    cout<<"enter the elements of matrix B:";
    for (int r=0;r<rows;r++)
     { for (int c=0;c<cols;c++)
       {
        cin>>B(r,c);
       }
  .............
    }
    else if(x==2)
  {  cout<<"enter the dimension of matrix A:";
    cin>>rows>>cols;
    Matrix A = Matrix(cols, rows);
    cout<<"enter the elements of matrix A:";
    for (int r=0;r<rows;r++)
     { for (int c=0;c<cols;c++)
       {
        cin>>A(r,c);
       }
     }


    Matrix B = Matrix(cols, rows);
    cout<<"enter the elements of matrix B:";
    for (int r=0;r<rows;r++)
     { for (int c=0;c<cols;c++)
       {
        cin>>B(r,c);
       }
     }
    Matrix C;
     C = A - B;
    printf("A - B = \n");
    C.Print();
    printf("\n");
  }
   else if (x==3)
   {
     cout<<"enter the dimension of matrix A:";
    cin>>rows>>cols;
    Matrix A = Matrix(cols, rows);
    cout<<"enter the elements of matrix A:";
    for (int r=0;r<rows;r++)
     { for (int c=0;c<cols;c++)
       {
        cin>>A(r,c);
       }
     }


    Matrix B = Matrix(cols, rows);
    cout<<"enter the elements of matrix B:";
    for (int r=0;r<rows;r++)
     { for (int c=0;c<cols;c++)
       {
        cin>>B(r,c);

推荐答案

调试程序,

并逐行浏览,如果失败,将提示错误,读取错误并找出错误,可能是访问冲突错误
Debug your program,

and go through line by line, when it would fail it will prompt an error read the error and figure the error out, Its probably access violation error


这篇关于程序在运行时失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆