| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
哪位大侠帮我看看,谢谢啦~#include <stdio.h>
#include <string.h>
#define MAX_LEN 2005
int array[MAX_LEN] = {0};
int OutputResult(int array[], int low, int high, int i );
int MinValue(int a, int b);
int main()
{
int input = 0;
int i = 0;
int maxProfile = 0;
scanf("%d", &input);
for( i = 0; i < input; i++ )
{
scanf("%d", &array[i]);
}
maxProfile = OutputResult( array, 0, input - 1, 1);
printf("%d\n", maxProfile);
return 0;
}
int OutputResult( int array[], int low, int high, int i)
{
int minValue = 0;
int static totleValue = 0;
if(low == high)
{
totleValue += i * array[low];
return totleValue;
}
minValue = MinValue(array[low], array[high]);
if( minValue == array[low] )
{
totleValue = i*array[low] + OutputResult(array, low + 1, high, i+1);
}
else
{
totleValue = i*array[high] + OutputResult(array, low, high - 1, i+1);
}
return totleValue;
}
int MinValue(int a, int b)
{
return (a > b)? b : a;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator