CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  专题开发/技术/项目 >  数据结构与算法

城市公交车线路查询算法!急!

楼主hhdn(想高飞的小小鸟)2003-01-08 16:25:10 在 专题开发/技术/项目 / 数据结构与算法 提问

小弟我做课程设计要用到这个算法,有哪位大侠帮我一把,不胜感激! 问题点数:20、回复次数:6Top

1 楼frman()回复于 2003-01-08 20:43:29 得分 0

说具体点,不过我一看“公交车”感觉不是DIJKSTRA就是DP   :)Top

2 楼qrlvls( 空 气 )回复于 2003-01-08 20:54:25 得分 0

数据结构中应该有现成的东西,图的最短路径嘛!  
  呵呵,考虑考虑先。Top

3 楼hhdn(想高飞的小小鸟)回复于 2003-01-09 08:43:18 得分 0

小弟我的课程设计是用Oracle8i作后台数据库,前台用java编写动态网页,  
  我对系统运行环境的选择  
  (1)服务器端软件环境  
  操作系统:RedHat   Linux8.0  
  数据库系统:Oracle   8.1.7   Universal   Server  
  (2)客户机端软件环境  
  浏览器:Internet   Explorer、Netscape   Communicator等  
  (3)应用开发环境  
  使用SOL、PL/SQL语言编写能产生动态交互式WEB页面的存储过程及软件包;使用Jbuilder7编写静态JSP网页页面。  
  但是,我现在不知道是用java编写查询算法还是用Oracle的PL/SQL编写算法  
  我想用弗洛伊德算法,但怎么将他转化为具体的java或PL/SQL代码,有哪位大侠好心能把算法提供给我,江湖救急呀!!!,不胜感激!!!Top

4 楼eion(那个谁)回复于 2003-01-09 14:15:31 得分 0

给100分吧  
  我把源码给你贴出来Top

5 楼eion(那个谁)回复于 2003-01-09 14:15:57 得分 20

#include   <string.h>  
   
  /*##/*~~~~~~~~~~   Noted   by   Tang   Houjian(&Igrave;&AElig;&ordm;&ntilde;&frac14;ó)[2002-6-21   10:30:39]   ~~~~~~~~~~~*/  
  /*  
  /* &sup3;&Euml;×&oslash;&sup1;&laquo;&sup1;&sup2;&AElig;&ucirc;&sup3;&micro;&Ecirc;±&micro;&Auml;&raquo;&raquo;&sup3;&micro;&Icirc;&Ecirc;&Igrave;&acirc;&iexcl;&pound;&Agrave;&yacute;&Egrave;&ccedil;&acute;&Oacute;&Otilde;&frac34;A&micro;&frac12;Z&Ograve;&ordf;×&oslash;&frac14;&cedil;&Acirc;·&sup3;&micro;&pound;&not;&raquo;&raquo;&frac14;&cedil;&acute;&Icirc;&pound;&not;&Ocirc;&Uacute;&Auml;&Auml;&Agrave;&iuml;&raquo;&raquo;&sup3;&micro;&pound;&not;&Otilde;&acirc;&ETH;&copy;&Icirc;&Ecirc;&Igrave;&acirc;&Egrave;&ccedil;&ordm;&Icirc;&frac12;&acirc;&frac34;&ouml;&iexcl;&pound;  
  /* &sup3;&micro;&acute;&Icirc;&iexcl;&iexcl;&iexcl;&iexcl;&sup3;&micro;&Otilde;&frac34;  
  /* 1&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;q,w,e,r,t,y  
  /* 2&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;a,s,d,f,g,h  
  /* 3&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;&iexcl;z,x,c,v,b,n  
  /* 4&iexcl;&iexcl;&iexcl;&iexcl;     p,o,i,u,y,t  
  /* 5&iexcl;&iexcl;&iexcl;&iexcl;     l,k,j,h,g,f  
  /* 6&iexcl;&iexcl;&iexcl;&iexcl;     m,n,b,v,c,x  
  /* 7&iexcl;&iexcl;&iexcl;&iexcl;     q,a,z,w,s,x  
  /*  
  /*________________   Ended   Note   [2002-6-21   10:30:39]   _____________________##*/  
   
  #define   M   7     //   &sup3;&micro;&acute;&Icirc;&Ecirc;&yacute;  
   
  //   &sup3;&micro;&acute;&Icirc;&Iacute;&pound;&iquest;&iquest;&Otilde;&frac34;&Aacute;&ETH;±í  
  char   *Station[M]   =   {  
  "QWERTY",   //   &micro;&Uacute;0&acute;&Icirc;&sup3;&micro;  
  "ASDFGH",   //   &micro;&Uacute;1&acute;&Icirc;&sup3;&micro;  
  "ZXCVBN",   //   &micro;&Uacute;2&acute;&Icirc;&sup3;&micro;  
  "POIUYT",   //   &micro;&Uacute;3&acute;&Icirc;&sup3;&micro;  
  "LKJHGF",   //   &micro;&Uacute;4&acute;&Icirc;&sup3;&micro;  
  "MABVCX",   //   &micro;&Uacute;5&acute;&Icirc;&sup3;&micro;  
  "QAZWSX"};//   &micro;&Uacute;6&acute;&Icirc;&sup3;&micro;  
   
  //   &Ograve;&Ntilde;&frac34;&shy;&sup3;&Euml;×&Aring;&sup1;&yacute;&micro;&Auml;&sup3;&micro;&acute;&Icirc;&Aacute;&ETH;±í&pound;&not;&para;&Ocirc;&Oacute;&brvbar;take[i]=0±í&Ecirc;&frac34;&raquo;&sup1;&Icirc;&acute;&sup3;&Euml;×&Aring;&pound;&not;&pound;&frac12;1±í&Ecirc;&frac34;&Ograve;&Ntilde;&frac34;&shy;&sup3;&Euml;×&Aring;&sup1;&yacute;  
  int     taked[M]={0,0,0,0,0,0,0};  
   
  //   &raquo;&raquo;&sup3;&micro;&micro;&Auml;&Iuml;&Acirc;&sup3;&micro;&micro;&atilde;  
  struct   Exchange  
  {  
  static   int   Len;   //   &sup3;¤&para;&Egrave;  
  int   route;             //   &sup3;&micro;&acute;&Icirc;  
  char   pos;               //   &raquo;&raquo;&sup3;&micro;&Otilde;&frac34;&micro;&atilde;  
  }   Path[M];                     //   &raquo;&raquo;&sup3;&micro;&Acirc;·&frac34;&para;  
   
  int   Exchange::Len   =   0;   //   &sup3;&otilde;&Ecirc;&frac14;&raquo;&macr;&Acirc;·&frac34;&para;&sup3;¤&para;&Egrave;  
   
  bool   PassBy(char   P,   char*   path)   //   &iquest;&acute;&Acirc;·&frac34;&para;path&micro;&Auml;&sup3;&micro;&Ecirc;&Ccedil;·&ntilde;&frac34;&shy;&sup1;&yacute;&micro;&atilde;P  
  {  
  while(*path!='\0')   if(   P==*(path++)   )   return   true;  
  return   false;  
  }  
   
  //   &acute;ò&Oacute;&iexcl;&Acirc;·&frac34;&para;&pound;&not;&Atilde;&raquo;&micro;&Atilde;&Euml;&micro;  
  void   print_path()    
  {  
  static   int   cnt   =   0;  
  printf("%04d",++cnt);  
  for(int   i=0;i<Path[0].Len-1;i++)  
  printf("   (%2d:   %c)   -->   ",Path[i].route+1,Path[i].pos);  
  printf("   (%2d:   %c)   ",Path[i].route+1,Path[i].pos);  
  printf("\n");  
  }  
  void   NextSearchPath(char   end,int   route)   //   &micro;&Yacute;&sup1;é&Ntilde;°&Otilde;&Ograve;&Acirc;·&frac34;&para;  
  {  
  if(   taked[route]!=0   )   return;     //   have   been   taked;  
   
  if(   PassBy(end,Station[route])   )    
  {  
  Path[Path[0].Len].pos   =   end;  
  Path[Path[0].Len].route   =   route;  
  Path[0].Len++;  
  print_path();  
  Path[0].Len--;  
  return;  
  }  
  taked[route]   =   1;   //have   been   taked;  
  Path[Path[0].Len].route   =   route;  
   
  for(int   i=0;i<strlen(Station[route]);i++)    
  {  
  char   nowPos   =   Station[route][i];  
  if(   nowPos==Path[Path[0].Len-1].pos   )   continue;  
  for(   int   j=0;   j<M;   j++)   if(   PassBy(nowPos,Station[j])   )  
  {  
  Path[Path[0].Len].pos   =   nowPos;  
  Path[0].Len++;  
  NextSearchPath(end,j);  
  Path[0].Len--;  
  }  
  }  
  taked[route]   =   0;   //have   been   taked;  
   
  }  
  void   SearchPath(char   start,   char   end)  
  {  
  for(int   i=0;i<M;i++)   if(   PassBy(start,Station[i])   )  
  {  
  Path[Path[0].Len].pos   =   start;  
  Path[Path[0].Len].route   =   i;  
  Path[0].Len++;  
  NextSearchPath(end,i);  
  Path[0].Len--;  
  }  
  }  
   
  void   main()  
  {  
  SearchPath('A','Z');  
  }  
  //&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;&pound;&shy;  
  Top

6 楼eion(那个谁)回复于 2003-01-09 14:19:40 得分 0

What?我的注释!!!!!!!!!!!!!!  
   
  //   乘车方案.cpp   :   Defines   the   entry   point   for   the   console   application.  
  //  
   
  #include   "stdafx.h"  
  #include   <string.h>  
   
  /*##/*~~~~~~~~~~   Noted   by   [2002-6-21   10:30:39]   ~~~~~~~~~~~*/  
  /*  
  /* 乘坐公共汽车时的换车问题。例如从站A到Z要坐几路车,换几次,在哪里换车,这些问题如何解决。  
  /* 车次  车站  
  /* 1   q,w,e,r,t,y  
  /* 2   a,s,d,f,g,h  
  /* 3   z,x,c,v,b,n  
  /* 4       p,o,i,u,y,t  
  /* 5       l,k,j,h,g,f  
  /* 6       m,n,b,v,c,x  
  /* 7       q,a,z,w,s,x  
  /*  
  /*________________   Ended   Note   [2002-6-21   10:30:39]   _____________________##*/  
   
  #define   M   7     //   车次数  
   
  //   车次停靠站列表  
  char   *Station[M]   =   {  
  "QWERTY",   //   第0次车  
  "ASDFGH",   //   第1次车  
  "ZXCVBN",   //   第2次车  
  "POIUYT",   //   第3次车  
  "LKJHGF",   //   第4次车  
  "MABVCX",   //   第5次车  
  "QAZWSX"};//   第6次车  
   
  //   已经乘着过的车次列表,对应take[i]=0表示还未乘着,=1表示已经乘着过  
  int     taked[M]={0,0,0,0,0,0,0};  
   
  //   换车的下车点  
  struct   Exchange  
  {  
  static   int   Len;   //   长度  
  int   route;             //   车次  
  char   pos;               //   换车站点  
  }   Path[M];                     //   换车路径  
   
  int   Exchange::Len   =   0;   //   初始化路径长度  
   
  bool   PassBy(char   P,   char*   path)   //   看路径path的车是否经过点P  
  {  
  while(*path!='\0')   if(   P==*(path++)   )   return   true;  
  return   false;  
  }  
   
  //   打印路径,没得说  
  void   print_path()    
  {  
  static   int   cnt   =   0;  
  printf("%04d",++cnt);  
  for(int   i=0;i<Path[0].Len-1;i++)  
  printf("   (%2d:   %c)   -->   ",Path[i].route+1,Path[i].pos);  
  printf("   (%2d:   %c)   ",Path[i].route+1,Path[i].pos);  
  printf("\n");  
  }  
  void   NextSearchPath(char   end,int   route)   //   递归寻找路径  
  {  
  if(   taked[route]!=0   )   return;     //   have   been   taked;  
   
  if(   PassBy(end,Station[route])   )    
  {  
  Path[Path[0].Len].pos   =   end;  
  Path[Path[0].Len].route   =   route;  
  Path[0].Len++;  
  print_path();  
  Path[0].Len--;  
  return;  
  }  
  taked[route]   =   1;   //have   been   taked;  
  Path[Path[0].Len].route   =   route;  
   
  for(int   i=0;i<strlen(Station[route]);i++)    
  {  
  char   nowPos   =   Station[route][i];  
  if(   nowPos==Path[Path[0].Len-1].pos   )   continue;  
  for(   int   j=0;   j<M;   j++)   if(   PassBy(nowPos,Station[j])   )  
  {  
  Path[Path[0].Len].pos   =   nowPos;  
  Path[0].Len++;  
  NextSearchPath(end,j);  
  Path[0].Len--;  
  }  
  }  
  taked[route]   =   0;   //have   been   taked;  
   
  }  
  void   SearchPath(char   start,   char   end)  
  {  
  for(int   i=0;i<M;i++)   if(   PassBy(start,Station[i])   )  
  {  
  Path[Path[0].Len].pos   =   start;  
  Path[Path[0].Len].route   =   i;  
  Path[0].Len++;  
  NextSearchPath(end,i);  
  Path[0].Len--;  
  }  
  }  
   
  void   main()  
  {  
  SearchPath('A','Z');  
  }  
  //---------------------------------------------  
   
  Top

相关问题

  • 关于查询公交车线路换乘的算法!
  • 公交车站点查询的算法讨论
  • 用C/C++来实现公交车线路查询
  • 100分求公交车转车查询
  • 欢迎大家讨论公交车换乘算法,来者给分
  • 急呀!想请教各位高手一个公交车换乘算法!
  • ################# 求一条SQL语句,关于公交车换乘查询 #################
  • 请问公交车站查询的SQL语句怎么写?
  • 求多条件查询算法
  • 复杂的查询算法,请帮忙

关键词

  • 算法
  • oracle
  • sql
  • frac
  • route
  • 路径
  • path
  • 换车
  • passby
  • taked

得分解答快速导航

  • 帖主:hhdn
  • eion

相关链接

  • CSDN Blog
  • 技术文档
  • 代码下载
  • 第二书店
  • 读书频道

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo