题解 | #最高身高#

最高身高

http://www.nowcoder.com/practice/258fe0c567ac493f9b7bc9d3669d158d

用一维数组写的,写麻烦了呢,哈哈

#include<stdio.h>
#include<math.h>
int main()
{
    int n = 1, m = 1, high = 0;
    float locat = 0;
    int arr[100] = { 0 };
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m * n; i++)
    {
        scanf("%d", &arr[i]);
        if (i == 0)
        {
            locat = 1.0;
            high = arr[0];
        }
        else
        {
            if (arr[i] > high)
            {
                locat = i + 1.0;
                high = arr[i];
            }
        }
    }
    int a = (int)ceil(locat / m);
    int b = (int)(locat - (ceil(locat / m)-1) * m);
    printf("%d %d",a,b);
    return 0;
}
全部评论

相关推荐

评论
点赞
收藏
分享
牛客网
牛客企业服务