一道acm题 题目是Number Triangle 我的程序样例可以通过 但是无法AC 提示wa 不懂有什么问题了

一道acm题 题目是Number Triangle 我的程序样例可以通过 但是无法AC 提示wa 不懂有什么问题了
Problem Description
Consider the number triangle shown below.Write a program that calculates the highest sum of numbers that can be passed on a route that starts at the top and ends somewhere on the base.Each step can go either diagonally down to the left or diagonally down to the right.
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
In the sample above,the route from 7 to 3 to 8 to 7 to 5 produces the highest sum:30.
Input
There are multiple test cases.The first line of each test case contains R (1 sz;
int **arr=new int *[sz];
for(int i=0;i=0;i--)
{
for(int j=0;jarr[i+1][j+1]?arr[i+1][j]:arr[i+1][j+1]);
arr[i][j]=arr[i][j]+max;
}
}
cout
lilucy 1年前 已收到1个回答 举报

浓NONG 幼苗

共回答了20个问题采纳率:95% 举报

这道题相当恶心.
会多次输入testcase
你的程序改成这样就AC了.
#include
#include
using namespace std;
int main()
{
int n;
double a,b,c,d,e,f,x,y;
while(1)
{
cin>>n;
if(n==0) break;
for(int i=1;i<=n;i++)
{if(n==0) break;
cin>>a>>b>>c>>d>>e>>f;
x=(a+c+e)/3;
y=(b+d+f)/3;
cout<}
}
return 0;
}
就是多增加一个循环.这道题就是坑人啊~

1年前

7
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 1.618 s. - webmaster@yulucn.com