#include <stdio.h>

#define N 4

int fun(int *arr)
{
    int i,j;
    int x,y;
    int temp;
    int a[N];

    for(j = 0; j < N; j++)    
    {
        x = j;
        y = j;
        for(i = 0; i< x; i++)
        {
            if(x > 0)
            {
                if(arr[j]<arr[x-1])
                    x--;
                else break;
            }
        }
        for(i = y; i< N; i++)
        {
            if(y < N)
            {
                if(arr[j]<arr[y+1])
                    y++;
                else break;
            }
        }
        a[j] = (y-x+1)*arr[j];
    }
    
    temp = a[0];
    for(j = 0; j < N; j++)
    {
        if(a[j]>temp)
            temp = a[j];
    }
    return temp;
}


int main()
{
    //int arr[N] = {2,1,5,6,2,3};
    //int arr[N] = {1,2,3,4,5,6};
    int arr[N] = {4,0,1,1};
    int w = fun(arr);
    printf("%d\n", w);
return 0; }

 

相关文章:

  • 2021-08-16
  • 2022-12-23
  • 2021-12-08
  • 2021-04-26
  • 2021-08-28
  • 2022-12-23
  • 2021-05-30
猜你喜欢
  • 2022-01-28
  • 2021-08-26
  • 2022-12-23
  • 2021-12-26
  • 2021-06-20
  • 2021-04-03
  • 2021-05-17
相关资源
相似解决方案