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 irence at 2012-10-31 23:40:51 on Problem 1163
#include <iostream>
#include<cstdio>
#include <math.h>
#include<string.h>
#include <stdio.h>
#include<stdlib.h>


using namespace std;

int main()
{
    int N,i,j,a[101][101];
    cin>>N;
    for(i=0;i<N;i++)
    {
        for(j=0;j<i+1;j++)
        {
            cin>>a[i][j];
        }
    }
    int last;

    for(i=N-1;i>0;i--)
    {
        for(j=0;j<=i;j++)
        {
            if(a[i][j]>a[i][j+1])a[i-1][j]+=a[i][j];
            else a[i-1][j]+=a[i][j+1];
        }

    }
    last=a[0][0];
    cout<<last<< endl;
    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