Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

没弄过。麻烦谁告诉我下,为什么会编译错误?

Posted by Stareven at 2009-10-22 11:33:31 on Problem 1050
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator