'commit'
This commit is contained in:
26
C++课程/第十九课活用数组下标/p200.cpp
Normal file
26
C++课程/第十九课活用数组下标/p200.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int MAXN=100001;
|
||||
int main() {
|
||||
int a[MAXN];
|
||||
int n,i,j,k;
|
||||
int maxsum;
|
||||
int temp;
|
||||
cin>>n;
|
||||
|
||||
for(i=1; i<=n; i++)
|
||||
cin>>a[i];
|
||||
maxsum=a[1];
|
||||
for(i=1; i<=n; i++)
|
||||
for(j=1; j<=n; j++) {
|
||||
temp=0;
|
||||
for(k=i; k<=j; k++)
|
||||
temp=temp+a[k];
|
||||
if(maxsum<temp) maxsum=temp;
|
||||
}
|
||||
cout<<maxsum;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user