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> #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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator