Ytu 2019: Saddle Point calculation __ytu

Source: Internet
Author: User
Tags first row
2019: Saddle Point calculationTime limit: 1 Sec memory limit: MB
Submitted: 66 Settlement: 30
Topic Description

Find the "saddle point" with a two-dimensional array of m rows n columns, where the element is the largest on the row, the smallest on the column, where 1<=m,n<=10. input

The input data has more than one row, the first row has two numbers m and N, the following has M row, each row has n number. Output

The saddle points are output in the following format: Array[i][j]=x where x represents the saddle point, I and J are the array row and column subscript for the saddle point, we specify that the array subscript start from 0. A two-dimensional array does not necessarily have a saddle point, so please output none at this time. We guarantee that there will be no two saddle points, such as:

3 3

1 2 3

1 2 3

3 6 8 Sample input

3 3
1 2 3 4 5 6 7 8 9

Sample Output
Array[0][2]=3


lost in the valley of the birds, flying alone in this huge world, but do not know where to fly to the side ...
#include <stdio.h>
int main ()
{
    int n,m,a[99][99],i,j,max,maxj;
    BOOL Flag;
    scanf ("%d%d", &n,&m);
    For (i=0 i<n; i++) for
        (j=0; j<m; j + +)
            scanf ("%d", &a[i][j]);
    for (i=0; i<n; i++)
    {
        max=a[i][0];
        maxj=0;
        For (j=0 j<m; j + +)
            if (Max<a[i][j])
            {
                max=a[i][j];
                maxj=j;
            }
        Flag=true;
        for (int k=0; k<n; k++)
            if (Max>a[k][maxj])
            {
                flag=false;
                Continue;
            }
        if (flag)
        {
            printf ("array[%d][%d]=%d", I,maxj,max);
            break;
        }
    }
    if (!flag) printf ("none\n");
    return 0;
}

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.