qq_32276847
qq_32276847
2015-11-13 13:48

请问我的程序到底哪里不符合?

5
  • c++
  • c
  • 程序
  • 杭电acm

杭电acm1003
#include
using namespace std;

long int input(long int x, int p1[])
{
long int j = 0;
while (j {
cin >> p1[j];
j++;
}
return j + 1;
}

void compare(long int y, int p2[], int a)
{
long int start = 1;
long int end = 1;
long int *sum = new long int[y + 1];
long long int max = sum[0];
p2[0]=sum[0];
for (long int k = 1;k < y - 1;k++)
{
if (sum[k - 1]<0)
{
sum[k] = p2[k];
start = end = k + 1;
}
else
{
sum[k] = sum[k - 1] + p2[k];
end++;
}
if (max<sum[k])
{
max = sum[k];
}
else
{
end--;
}
}
delete[]sum;
cout << "Case " << a << ":\n" << max << " " << start << " " << end << endl;
}

int main()
{
int n = 0;
long int m = 0;
cin >> n;
for (int i = 1; i <= n; i++)
{
long int T = 0;
cin >> T;
int num[100001];
m = input(T, num);
compare(m, num, i);
cout << endl;
}
return 0;
}
图片说明

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答