标签:stream print ring algo i+1 ios names mes queue
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <queue> using namespace std; int a[6][6],mp[6][6]; queue<int>Q; int main() { int n; while(1) { printf("请输入路径层数:(输入0结束)"); scanf("%d",&n); if(n==0)break; for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { scanf("%d",&a[i][j]); mp[i][j]=a[i][j]; } } for(int i=n-1;i>=1;i--) { for(int j=1;j<=i;j++) { if(mp[i+1][j]>mp[i+1][j+1]) {mp[i][j]+=mp[i+1][j];} else {mp[i][j]+=mp[i+1][j+1];} } } cout<<mp[1][1]<<endl; } return 0; }
标签:stream print ring algo i+1 ios names mes queue
原文地址:http://www.cnblogs.com/lijunzone/p/7640678.html