![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
编程算法
文章平均质量分 67
行走在遗忘的边缘
年少轻狂无知欤,蓦然回首梦已失!
展开
-
算法作业—数字三角形问题
#include"iostream"#include"fstream"using namespace std;int N;int a[100][100];/**计算和最大路径的值**/int sumMax() { int i,j; int sum = 0; for(i = N; i > 0; i--) { for(j = 0; j <...2014-05-28 22:06:08 · 358 阅读 · 0 评论 -
算法作业—汽车加油问题
一辆汽车加满油后可以行驶N千米。旅途中有若干个加油站。指出若要使沿途的加油次数最少,设计一个有效的算法,指出应在那些加油站停靠加油。 给出N,并以数组的形式给出加油站的个数及相邻距离,指出若要使沿途的加油次数最少,设计一个有效的算法,指出应在那些加油站停靠加油。一辆汽车加满油后可以行驶N千米。旅途中有若干个加油站。指出若要使沿途的...原创 2014-06-25 20:48:15 · 643 阅读 · 0 评论 -
Catch That Cow
DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point...2014-07-01 19:56:50 · 102 阅读 · 0 评论 -
算法作业—数字三角形问题
for(j = 0; j < N; 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]; } } } return a[0][0];}/**主函数,输入和输出数据**/void main() { int i,j,n = 1; ifstream infile("inpu2014-05-28 22:06:08 · 148 阅读 · 0 评论 -
算法作业—汽车加油问题
原创 2014-06-25 20:48:15 · 217 阅读 · 0 评论 -
Catch That Cow
a point K (0 ≤ K ≤ 100,000) on the same number line. Farmer John has two modes of transportation: walking and teleporting.* Walking: FJ can move from any point X to the points X - 1 or X + 1 in a single minute* Teleporting: FJ can move from any point X2014-07-01 19:56:50 · 74 阅读 · 0 评论