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<iostream> using namespace std; int n,a[101][101],maxm=-200; void in() { cin>>n; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) { cin>>a[i][j]; if (maxm<a[i][j]) maxm=a[i][j]; } } void fill(int x[101],int y) { for (int i=0;i<=n;i++) x[i]=y; } void add(int x[101],int y[101]) { for (int i=1;i<=n;i++) x[i]+=y[i]; } int max(int x,int y) { int z; z=(x>y)?x:y; } void out() { cout<<maxm; } int main() { in(); if (maxm<0) { cout<<maxm; // system("PAUSE"); return 0; } int f[101]; for (int i=1;i<=n;i++) { int b[101]; fill(b,0); for (int j=i;j<=n;j++) { add(b,a[j]); fill(f,0); for (int k=1;k<=n;k++) { f[k]=max(b[k],f[k-1]+b[k]); if (f[k]<0) f[k]=0; if (f[k]>maxm) maxm=f[k]; } } } out(); // system("PAUSE"); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator