最佳浏览路线问题 算法设计
来源:互联网 发布:乐1pro刷机包优化内核 编辑:程序博客网 时间:2024/05/16 07:20
#include<stdio.h>#include<stdlib.h>void findbestpath(int s[] , int n ,int &s1 ,int &s2);int main(void){int a[3][5] = {-50 , -47 , 36 , -30 , -23 , 17 , -19 , -34 , -43 , -8 ,-42 , -3 , -43 , 34 , -45 } ;int s[5] = {-100 , -100 , -100 , -100 , -100};for(int j = 0 ; j < 5 ; j++){ for(int i = 0 ; i < 3 ;i++) { if(s[j] < a[i][j]) { s[j] = a[i][j]; } }} int s1 = 0 , s2 = 0; findbestpath( s , 5 , s1 ,s2 );printf("the best path is :");for(int i = s1 ; i <= s2 ; i++){ printf("%d\t",s[i]);} printf("\n"); return 0;}void findbestpath(int s[] , int n , int &s1 ,int &s2 ){ int value = 0 , sum = 0 ; for(int i = 0 ; i < n ; i++) { sum = sum + s[i]; if(sum > value) { value = sum ; s2 = i; } if(sum < 0) { sum = 0 ; } } int temp = value ; s1 = s2; while(temp) { temp = temp - s[s1]; s1--; } s1++;}
0 0
- 最佳浏览路线问题 算法设计
- 最佳浏览路线问题
- 最佳浏览路线问题
- 最佳浏览路线
- SSL JudgeOnline 1210——最佳浏览路线
- 路线规划算法设计要点
- 四大UX设计原则,打造网站最佳浏览体验
- 最佳java学习路线
- 最佳旅游路线
- Android学习最佳路线
- Vijos P1423 最佳路线
- 校运会组织最佳路线
- 最佳旅游路线
- 设计路线
- 公交车路线查询系统后台数据库设计——查询算法
- 公交车路线查询系统后台数据库设计——查询算法
- 公交车路线查询系统后台数据库设计--查询算法
- Adobe Flex最佳学习路线
- Android中View的事件分发机制
- 阶乘统计0个数 算法
- SlidingMenu开源库
- 杨辉三角问题 算法编程
- 正则表达式校验身份证号
- 最佳浏览路线问题 算法设计
- spring ioc和DI理解
- 通过userAgent判断手机浏览器类型
- HDOJ 2040 亲和数
- 51nod 1086
- react学习札记(一)
- hdu5612
- meanshift跟踪算法总结
- python之10分钟pandas