07年B题最优公交线路问题(10)
附录:(注:所有程序均使用Microsoft Visual Studio 2005 C#语言编写) 程序一(第一题优化转乘次数程序):
using System; using System.IO;
using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text;
using System.Windows.Forms; using System.Globalization; using System.Collections;
using System.Windows.Forms.Design;
namespace model {
public partial class Form1 : Form {
public Form1() {
InitializeComponent(); }
public struct line {
public char price; public char direct; public int[,] stop; }
public static int count = 0, goal = 2, money = 99, distance = 9999; public static int[] route = new int[10];
public static int[,] mon = new int[3958, 3958];
public void loop(int x, int y) {
distance = 9999;
if (dis[x, y] < distance) {
distance = dis[x, y]; goal = count;
31
}
count++;
if (count > 2) {
count --; return; }
for (int i = 1; i < 3958; i++) {
if (dis[x, i] + dis[i, y] + 10 < distance) {
distance = dis[x, i] + dis[i, y] + 10; route[count] = i; goal = count; } }
count++;
if (count > 2) {
count -= 2; return; }
for (int i = 1; i < 3958; i++) {
for (int j = 1; j < 3958; j++) {
if (dis[x, i] != 9999 && dis[j, y] != 9999 && i != j) {
if (dis[x, i] + dis[j, y] + 20 + dis[i,j] < distance) {
distance = dis[x, i] + dis[j, y] + 20 + dis[i,j]; route[count] = i; route[count + 1] = j; goal = count; } } }
32
}
count -= 2; return; }
private void Form1_Load(object sender, EventArgs e) {
FileStream info = new FileStream(\竞赛\\\\info.txt\FileAccess.ReadWrite),
infor = new FileStream(\竞赛\\\\infor.txt\FileMode.Open, FileAccess.ReadWrite);
StreamReader sr = new StreamReader(infor);
int flag = 0;
string a = string.Empty; line[] city = new line[521];
a = sr.ReadToEnd(); sr.Close(); infor.Close();
for (int i = 0, j = 0, h = 0, k = 0; i < a.Length; i++) {
switch (flag) {
case 0: {
if (a[i] == 'S') {
city[j].stop[k, h] = Convert.ToInt32(a.Substring(i + 1, 4));
h++; }
else if (a[i] == 'D') {
k = 1; h = 0; flag = 0; }
else if (a[i] == 'L') {
if (k == 0)
33
{
if (city[j].direct == 'S')
相关推荐:
- [实用模板]第八章:法国“新浪潮”与“左岸派”
- [实用模板]2021年北京上半年临床医学检验技师生物
- [实用模板]SAP GUI 7.10客户端安装配置文档
- [实用模板]2001年临床执业医师资格考试综合笔试试
- [实用模板]36机场工作实用英语词汇总结
- [实用模板](一)社会保险稽核通知书
- [实用模板]安全教育主题班会材料
- [实用模板]濉溪县春季呼吸道传染病防控应急演练方
- [实用模板]长沙房地产市场周报(1.30-2.3)
- [实用模板]六年级数学上册典中点 - 图文
- [实用模板]C程序设计(红皮书)习题官方参考答案
- [实用模板]中国证监会第一届创业板发行审核委员会
- [实用模板]桥梁工程复习题
- [实用模板]2011学而思数学及答案
- [实用模板]初中病句修改专项练习
- [实用模板]监理学习知识1 - 图文
- [实用模板]小机灵杯四年级试题
- [实用模板]国贸专业毕业论文模板
- [实用模板]教育学概论考试练习题-判断题4
- [实用模板]2015届高考英语一轮复习精品资料(译林
- 00Nkmhe_市场营销学工商管理_电子商务_
- 事业单位考试法律常识
- 诚信教育实施方案
- 吉大小天鹅食品安全检测箱方案(高中低
- 房地产销售培训资料
- 高一地理必修1复习提纲
- 新概念英语第二册lesson_1_练习题
- 证券公司内部培训资料
- 小学英语时间介词专项练习
- 新世纪英语专业综合教程(第二版)第1册U
- 【新课标】浙教版最新2018年八年级数学
- 工程建设管理纲要
- 外研版 必修一Module 4 A Social Surve
- Adobe认证考试 AE复习资料
- 基于H.264AVC与AVS标准的帧内预测技术
- 《食品检验机构资质认定管理办法》(质
- ABB变频器培训课件
- (完整版)小学说明文阅读练习题及答案
- 深思洛克(SenseLock) 深思IV,深思4,深
- 弟子规全文带拼音




