码迷,mamicode.com
首页 > 编程语言 > 详细

c 语言鞍点问题处理

时间:2016-01-13 20:00:47      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:鞍点问题   c语言   

#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

解释权来自去转盘网,转载请告知

*/

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;

            }

        }//找到行中最小的,并记下他的下标

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

        {

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

                break;

        }//查看是否是列中最大的

        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

解释权来自去转盘网,转载请告知

*/

int main()

{



    Matrix M;



    Creat(M);

    Display(M);

    Destroymatrix(M);

    return 0;

}



c 语言鞍点问题处理

标签:鞍点问题   c语言   

原文地址:http://5912119.blog.51cto.com/5902119/1734718

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!