C-language saddle point problem processing

Source: Internet
Author: User

#include <iostream>

#define OK 1

#define ERROR 0


using namespace Std;

typedef int ELEMTYPE;

typedef struct MATRIX

{

Elemtype **a;

int cloumn,row;

} *matrix,matrix;


/*

Www.quzhuanpan.com

Interpretation of the power from the turntable network, reprint please inform

*/

Elemtype creat (Matrix &m)

{


int i,j;

cin>>m->row>>m->cloumn;

M->a=new int*[m->row];

for (i=0; i<m->row; i++)

{

M->a[i]=new int[m->cloumn];

}

for (i=0; i<m->row; i++)

for (j=0; j<m->cloumn; j + +)

cin>>m->a[i][j];

return OK;

}


int Display (Matrix &m)

{


int mark_y;

int mark_x;

int temp;

int i,j;

for (i=0; i<m->row; i++)

{

temp=m->a[i][0];

Mark_x=i;

mark_y=0;

for (j=1; j<m->cloumn; j + +)

{

if (m->a[i][j]<temp)

{

temp=m->a[i][j];

Mark_x=i;

Mark_y=j;

}

}//find the smallest line, and write down his subscript.

for (j=0; j<m->row; j + +)

{

if (m->a[j][mark_y]>temp)

Break

}//to see if it is the largest in the column

if (J==m->row)

{

cout<<mark_x<< "" <<mark_y<< "" <<temp<<endl;

return ERROR;

}

}

cout<< "Not found!" <<endl;

return OK;


}



int Destroymatrix (Matrix &m)

{



int i;

for (i=0;i<m->row;i++)

{

Delete []m->a[i];

}

Delete []m->a;

return OK;

}

/*

Www.quzhuanpan.com

Interpretation of the power from the turntable network, reprint please inform

*/

int main ()

{



Matrix M;



Creat (M);

Display (M);

Destroymatrix (M);

return 0;

}



C-language saddle point problem processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.