问题描述
- 请问我的程序到底哪里不符合?
-
杭电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;
}
解决方案
如果程序没错,注意空格之类的格式错误
解决方案二:
long int input(long int x, int p1[])
{
long int j = 0;
while (j { //这里是你复制错了,还是原来就错了。
解决方案三:
long int input(long int x, int p1[])
{
long int j = 0;
while (j { //这里是你复制错了,还是原来就错了