公交查询系统源代码(公交信息系统)
admin 发布:2022-12-19 04:43 98
今天给各位分享公交查询系统源代码的知识,其中也会对公交信息系统进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
- 1、请问你懂j2me公交查询系统不?像都市行那样的系统。我想分析下他的源代码,不是很懂。能否帮忙?
- 2、用C++编写一个公交查询系统
- 3、求公交线路查询系统的c语言程序
- 4、求大神发一个c语言写的代码 公交路线的查询 具体要求【用户能够方便查询某条公交路线的详细信息。】
- 5、城市公交查询系统用C++实现,具体就是输入此城市一个站点和另一个站点,告诉别人该怎么乘车?
- 6、用C++ 编 北京交通查询系统 先发100分
请问你懂j2me公交查询系统不?像都市行那样的系统。我想分析下他的源代码,不是很懂。能否帮忙?
和同学讨论过这个问题,主要涉及到地图的显示。
同学的意见是做成联网的,把公交车号或者乘车区间的站点发上去,让服务器返回地点或者是车次。
用C++编写一个公交查询系统
可以通过Baidu Hi通知我们你的任务
有机会可完成你遇到的任务
根据此题目
我们可以提供一份适合于学生水平的源码
如果你有相关的要求也可通知我们
ES:\\22637675B30DB4B220F8C7B9215B86FC
交易提醒:预付定金是诈骗
交易提醒:勿轻信用户名中的联系方式
求公交线路查询系统的c语言程序
这是我写的程序 希望能给你参考
#includestdio.h
#includeconio.h
#includestdlib.h
#includestring.h
#define NULL 0
int n=0;
int aa[20]={0};
struct road
{long num;
char stage[20][20];
struct road *next;
};
struct road *create()
{struct road *head,*p1,*p2;
int m,i;
char yes_no;
FILE *fp,*fp1;
fp=fopen("d:\\nizaoran.txt","w");
if(fp==NULL)
{printf("file cant be open\n");
exit(1);
}
fp1=fopen("d:\\record.txt","w");
if(fp1==NULL)
{printf("file can't be open\n");
exit(1);
}
head=NULL;
do
{p1=(struct road*)malloc(LEN);
printf("please input %d num:",n+1);
scanf("%ld",p1-num);
fprintf(fp,"%ld",p1-num);
printf("how many stages?");
scanf("%d",aa[n]);
fprintf(fp1,"%d\n",aa[n]);
for(i=0;iaa[n];i++)
{getchar();
printf("please input the %d station:",i+1);
gets(p1-stage[i]);
fprintf(fp," %s",p1-stage[i]);
}
fputc('\n',fp);
p1-next=NULL;
n++;
if(n==1) head=p1;
else p2-next=p1;
p2=p1;
printf("do you want to continue (Y/N)?");
scanf("%c",yes_no);
}while(yes_no=='y'||yes_no=='Y');
fclose(fp);
free (p1);
return head;
}
void add()
{
struct road temp;
int i=0;
FILE *fp;
fp=fopen("d:\\nizaoran.txt","a");
printf("input the route you want to add:");
scanf("%ld",temp.num);
fprintf(fp,"%ld",temp.num);
printf("please input how many stages:");
scanf("%d",aa[n]);
while(iaa[n])
{getchar();
printf("please input the %d stage\n",i+1);
gets(temp.stage[i]);
fprintf(fp," %s",temp.stage[i]);
i++;
}
fprintf('\n',fp);
n++;
fclose(fp);
}
void display()
{FILE *fp;
char ch;
if((fp=fopen("d:\\nizaoran.txt","r"))==NULL)
{printf("cant open file\n");
exit(1);
}
while(!feof(fp))
{ch=fgetc(fp);
printf("%c",ch);
}
fclose(fp);
}
void modify()
{ FILE *fp;
struct road temp[20];
char a[6],b[20],ch;
int i=0,j=0,k=0,m=0,t=0;
long num;
if((fp=fopen("d:\\nizaoran.txt","r"))==NULL)
{printf("cant open file\n");
exit(1);
}
for(i=0;in;i++)
{fscanf(fp,"%ld",temp[i].num);
printf("%ld ",temp[i].num);
for(j=0;jaa[i];j++)
{fscanf(fp,"%s",temp[i].stage[j]);
putchar(' ');
puts(temp[i].stage[j]);
}
fgetc(fp);
}
fclose(fp);
printf("which do you want to modify(num/stage)?");
getchar();
gets(a);
if(strcmp("num",a)==0)
{printf("which num:");
scanf("%ld",num);
if((fp=fopen("d:\\nizaoran.txt","w"))==NULL)
{printf("cant open file\n");
exit(1);
}
for(j=0;jn;j++)
if(temp[j].num==num)
{printf("please input the right num:");
scanf("%ld",temp[j].num);
break;
}
if(j==n) printf("no find\n");
}
else if(strcmp("stage",a)==0)
{if((fp=fopen("d:\\nizaoran.txt","w"))==NULL)
{printf("cant open file\n");
exit(1);
}
printf("the num and the stage:");
scanf("%ld%s",num,b);
for(j=0;jn;j++)
{if(temp[j].num==num)
{ for(i=0;iaa[j];i++)
if(strcmp(temp[j].stage[i],b)==0)
{printf("please input the right stage\n");
getchar();
gets(temp[j].stage[i]);
break;
}
if(i==aa[j])
printf("no fould");
break;
}
}
if(j==n)
printf("no found\n");
}
for(i=0;in;i++)
{fprintf(fp,"%ld",temp[i].num);
for(j=0;jaa[i];j++)
fprintf(fp," %s",temp[i].stage[j]);
fputc('\n',fp);
}
fclose(fp);
}
void delete()
{FILE *fp;
long num;
struct road temp[20];
int i=0,j=0;
if((fp=fopen("d:\\nizaoran.txt","r"))==NULL)
{printf("cant open file\n");
exit(1);
}
for(i=0;in;i++)
{fscanf(fp,"%ld",temp[i].num);
printf("%ld",temp[i].num);
for(j=0;jaa[i];j++)
{fscanf(fp,"%s",temp[i].stage[j]);
putchar(' ');
puts(temp[i].stage[j]);
}
fgetc(fp);
}
fclose(fp);
printf("input the num you want to delete\n");
scanf("%ld",num);
for(i=0;in;i++)
{
if(temp[i].num==num)
break;
}
if(i==n)
{printf("no found\n");
return;
}
else
{
temp[i].num=0;
}
fp=fopen("d:\\nizaoran.txt","w");
for(i=0;in;i++)
{
if(temp[i].num!=0)
{
fprintf(fp,"%ld",temp[i].num);
printf("%ld",temp[i].num);
for(j=0;jaa[i];j++)
{fprintf(fp," %s",temp[i].stage[j]);
putchar(' ');
puts(temp[i].stage[j]);
}
fputc('\n',fp);
putchar('\n');
}
}
fclose(fp);
n--;
printf("\n%d\n",n);
}
void search_num()
{
FILE *fp;
struct road temp[20];
int i,j,i1=0,j1=0;
long num;
if((fp=fopen("d:\\nizaoran.txt","r"))==NULL)
{printf("cant open file\n");
exit(1);
}
for(i=0;in;i++)
{fscanf(fp,"%ld",temp[i].num);
printf("%ld ",temp[i].num);
for(j=0;jaa[i];j++)
{fscanf(fp,"%s",temp[i].stage[j]);
putchar(' ');
puts(temp[i].stage[j]);
}
fgetc(fp);
}
fclose(fp);
printf("please input the number you want to search\n");
scanf("%ld",num);
for(i1=0;i1n;i1++)
{if(temp[i1].num==num)
break;
}
if(i1n)
{ printf("%ld",temp[i1].num);
for(j1=0;j1aa[i1];j1++)
{putchar(' ');
puts(temp[i1].stage[j1]);
}
putchar('\n');
}
else printf("no found\n");
}
void search_stage()
{
FILE *fp;
struct road temp[20];
int i,j,t,flag=0;
char a[20];
if((fp=fopen("d:\\nizaoran.txt","r"))==NULL)
{printf("cant open file\n");
exit(1);
}
for(i=0;in;i++)
{fscanf(fp,"%ld",temp[i].num);
printf("%ld ",temp[i].num);
for(j=0;jaa[i];j++)
{fscanf(fp,"%s",temp[i].stage[j]);
putchar(' ');
puts(temp[i].stage[j]);
}
fgetc(fp);
}
fclose(fp);
printf("please input the stage you want to search\n");
getchar();
gets(a);
for(i=0;in;i++)
for(j=0;jaa[i];j++)
if(strcmp(temp[i].stage[j],a)==0)
{printf("%ld",temp[i].num);
for(t=0;taa[i];t++)
{putchar(" ");
puts(temp[i].stage[t]);
}
putchar('\n');
flag=1;
}
if(flag==0) printf("no found\n");
}
void search_route()
{
FILE *fp;
struct road temp[20];
int i,j,first=0,second=0,fir=0,sec=0;
char a[20],b[20];
if((fp=fopen("d:\\nizaoran.txt","r"))==NULL)
{printf("cant open file\n");
exit(1);
}
for(i=0;in;i++)
{fscanf(fp,"%ld",temp[i].num);
printf("%ld ",temp[i].num);
for(j=0;jaa[i];j++)
{fscanf(fp,"%s",temp[i].stage[j]);
putchar(' ');
puts(temp[i].stage[j]);
}
fgetc(fp);
}
fclose(fp);
printf("please input the first stage\n");
getchar();
gets(a);
printf("please input the second stage\n");
getchar();
gets(b);
for(i=0;in;i++)
for(j=0;jaa[i];j++)
{if(strcmp(temp[i].stage[j],a)==0)
{first=i;
fir=j;
}
if(strcmp(temp[i].stage[j],a)==0)
{second=i;
sec=j;
}
}
if(first==second)
{if(firsec)
{t=fir;
fir=sec;
sec=t;
}
printf("%ld",temp[first].num);
for(t=fir;t=sec;t++)
{ putchar(" ");
puts(temp[fisrt].stage[t]);
}
}
else printf("not the same routine\n");
}
void search()
{int i;
printf("which way do you want(1,2,3):\n");
scanf("%d",i);
switch(i)
{case 1 : search_num();break;
case 2 : search_stage();break;
case 3 : search_route();break;
}
}
void fileout()
{FILE fp1;
int i;
if((fp1=fopen("d:\\recoord.txt","r"))==NULL);
{n=0;
for(i=0;i20;i++)
aa[i]=0;
}
else
{fscanf(fp1,"%d",n);
for(i=0;i20;i++)
fscanf(fp1," %d",aa[i]);
}
fclose(fp1);
}
void filein()
{FILE fp1;
int i,count=0;
if((fp1=fopen("d:\\recoord.txt","r"))==NULL)
{printf("file cant be opened\n");
exit(1);
}
else {fprintf(fp1,"%d",n);
for(i=0;i20;i++)
if(aa[i]0)
{fprintf(fp1," %d",aa[i]);
count++;
}
if(count20)
for(i=count;i20;i++)
fprintf(fp1,"%d",0);
}
fclose(fp1);
}
main()
{int choose;
char yes_no;
fileoout();
do
{clrscr();
printf("\t ******************************\n");
printf("\t please input your choose(0~6):\n");
printf("\t ******************************\n");
printf("\t ********1-create route********\n");
printf("\t ********2-display route*******\n");
printf("\t ********3-search route********\n");
printf("\t ********4-modify route********\n");
printf("\t ********5-add route***********\n");
printf("\t ********6-delete route********\n");
printf("\t ********0-exit****************\n");
printf("\t input your choose:");
scanf("%d",choose);
printf("\n");
switch(choose)
{case 1 : create();break;
case 2 : display();break;
case 3 : search();break;
case 4 : modify();break;
case 5 : add();break;
case 6 : delete();break;
case 0 : exit(0);
default: printf("error");
}
getchar();
printf("\n do you want to continue to choose menu (y/n)?\n");
do
{ yes_no=getchar();
}while(yes_no!='Y'yes_no!='y'yes_no!='N'yes_no!='n');
}while(yes_no=='Y'||yes_no=='y');
filiin();
}
求大神发一个c语言写的代码 公交路线的查询 具体要求【用户能够方便查询某条公交路线的详细信息。】
#include...
#define CHK_BY_LINE_ID 0
#define CHK_BY_BUS_ID 1
#define CHK_ERROR (-1)
#define MAX_LINE_ID 50
#define MAX_BUS_NUM 10
typedef struct
{
char bus_id[16];//公交车车牌号
unsigned char running_state;//运营状态,是收车了,还是在运营
unsigned short stop_id;//车站ID,表示公交车已经运行到哪个站了
unsigned char is_forward;//1表示从起点往终点开,0表示从终点往起点开
//其他你需要定义的内容,自己想吧
} BUS_INFO;//该结构体表示公交的信息
//公交车信息初始化
void init_bus_info(BUS_INFO **buses,int lines, int bus_numbers);
//打印公交车信息
void show_bus_info(BUS_INFO *buses, int lines);
//通过公交车线路编号,在buses中查询该线路的所有车辆信息
void search_bus_info_by_line_id(BUS_INFO **buses, unsignedshort line_id);
//通过公交车车牌号,在buses中查询该车的信息
void search_bus_info_by_bus_id(BUS_INFO **buses, char *bus_id_ptr);
//检查查询条件,是公交车线路编号,还是公交车车牌号,或无效的查询条件
int check_by_what(const char *key);
//循环函数
void loops(BUS_INFO **bus_info);
int main(int argc, char **argv)
{
//MAX_LINE_ID个线路,每个线路MAX_BUS_NUM辆车
BUS_INFO buses[MAX_LINE_ID][ MAX_BUS_NUM];
init_bus_info(buses, MAX_LINE_ID, MAX_BUS_NUM);//公交车信息初始化
loops(buses);//进程在此出于工作状态
return0; // 程序退出
}
void init_bus_info(BUS_INFO **buses,int line_numbers, int bus_numbers)
{
//初始化函数可以用手动输入信息的形式,也可以用自动的形式,我这里就用自动的方式了
//当然,手动形式初始化,函数的入参应采用另外的形式
int lines, bus;
for (lines=0; lines line_numbers; ++ lines)
for (bus = 0; bus bus_numbers; ++bus)
{
sprint(buses[lines][bus]. bus_id, “PRC-%d-%d”, lines, bus );//车牌号
buses[lines][bus]. running_state = 1;//运营中
buses[lines][bus]. stop_id = ((lines 8) 0x0000FF00)| (bus 0x000000FF);//位操作,lines为高字节号,bus为低字节号,两者共同构成车站号
buses[lines][bus]. is_forward = 1;
}
return;
}
int check_by_what(const char *key)
{
int i = 0;
int is_num = 1;
while (key[i] != ‘\0’)//未走到字符串尾部
{
if (key[i] = ‘0’ key[i] = ‘9’)
i++;
else
{
is_num = 0;
break;
}
}
if (is_num)//is_num未被置0,说明全是数字
return CHK_BY_LINE_ID;
//车牌号有效性检查
if(0 == strncmp(key, “PRC-”, 4))
return CHK_BY_BUS_ID;
else
returnCHK_ERROR;
}
void show_bus_info(BUS_INFO *buses, int lines)
{
printf(“LINE: %d BUS_ID:%s STATE:%d STOP_ID:%d IS_FORWARD:%d\n”,lines, buses-bus_id, buses-running_state,buses-stop_id, buses-is_forward);
return;
}
void search_bus_info_by_line_id(BUS_INFO **buses, unsignedshort line_id)
{
int index;
if(line_id= MAX_LINE_ID)//判断,防止数组越界
for (index=0; index MAX_BUS_NUM; index++)
show_bus_info(buses[line_id- 1][index], line_id);
else
printf(“Invalid bus line!!!\n”);
return;
}
void search_bus_info_by_bus_id(BUS_INFO **buses, char *bus_id_ptr)
{
int index1,index2;
int is_find = 0;
for (index1=0; index1 MAX_LINE_ID; ++index1 )
{
if(is_find )
break;//找到了,跳出外层循环
for (index2=0;index2 MAX_BUS_NUM; ++index2 )
if (0 ==strcmp(bus_id_ptr, buses[index1][index2].bus_id ))
{
show_bus_info(buses[index1][index2], index1);
is_find = 1;//is_find置为1,表示找到了,就不用再找了
// 因为车牌号是唯一的
break;//跳出内层循环
}
}
return;
}
void loops(BUS_INFO **bus_info)
{
char inputs[17];//为什么比车牌号缓冲区要多一个字符,自己想
int check_cond;
while (1)//死循环,学校教学的时候,告诉我们不能用这样的死循环
//今天在我看来,是错误的
//实际应用中,大多数后台进程都是死循环一直在运行
//关键是要在循环过程中,如何避免无谓的耗费cpu资源,如加阻塞函数
{
memset(inputs,0, sizeof(inputs));
printf(“Please input condition to search:”);
fflush(stdout);//上句没有“\n”,用此函数刷新标准输出
fgets(inputs, sizeof(inputs)-2, stdin);//从标准输入读取,是个阻塞函数
//没有输入时,一直停留在这一步,不耗费cpu资源;
inputs[strlen(inputs)-1] = 0;//把末尾换行符(不是我们想要的)替换为字符串的结束符
check_cond = check_by_what(inputs);
if (check_cond == CHK_BY_LINE_ID)
search_bus_info_by_line_id(bus_info,atoi(inputs));// atoi把字符串转化为数字
else if (check_cond == CHK_BY_BUS_ID)
search_bus_info_by_bus_id(bus_info, inputs);
else
printf(“Invalid condition!!!\n”);
}
return;//执行不到这一步,但还是写上,养成良好编程风格
}
先写到这里吧。不知道你是不是学生,为了完成作业,若是,这样可不好哦!
另外,该程序只有简单的查询功能,若想拓展新的功能,如:可实时更新公交车信息,可采用多线程编程,或其他方式。若你是学生的话,慢慢学吧,嘿嘿哟!
哎,刚直看了你的问题,没看到问题下面的要求。
公交车信息的录入,可以在loops函数里增加,要通过判断你从键盘输入了什么内容,比如格式化的命令,如:refresh info bus-id id running_state value。只是举个例子而已。
另外,也可以采用我上面说的多线程编程,这样更好,但是要主要互斥、加锁的问题。
由于本人是个上班的爷们,要是完成你所要的所有功能,非要写到半夜不可,所以就不给你多弄了,你自己学者弄吧。
城市公交查询系统用C++实现,具体就是输入此城市一个站点和另一个站点,告诉别人该怎么乘车?
假定 站点名唯一
mapstring,vectorstring value;保存了各路公交的过站情况
或者mapint,vectorint value;保存各路公交的过站代码情况 mapint ,string Type1,mapint,string分别保存代码与名称之间的关系
第一次搜索所有 一路公交上 含起点站和终点站的 显示所有符合的结果
第二次搜索:分别搜索所有分别含有起点和终点的公交(这次搜索之后保证输入站点 在公交系统中) 再两两搜索是否含有公共站点 所有含有公共站点的两个路线都显示 这次搜索之后保证输入站点 在公交系统中
第三次搜索:对所有含起点的路线的所有站点作为新起点,终点不变,套用第二次搜索的方式搜索
第四次搜索:对所有含终点的路线的所有站点作为新终点,套用第三次搜索的方式搜索
第五次搜索;你那城市成神了,第四次搜索是半神
用C++ 编 北京交通查询系统 先发100分
在PUDN上给你找了几个,看看行不
公交查询系统源代码 是武汉的 提供简单的查询和乘车方案 vc++
都是直接下载地址了。
关于公交查询系统源代码和公交信息系统的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
- 上一篇:智能家居系统源代码(智能家居代码实现)
- 下一篇:.net画图源代码(编程代码图)
相关推荐
- 05-19关于北京seo的信息
- 05-19关于河北seo的信息
- 05-18关于重庆网络推广的信息
- 05-18信息推广的方式有哪些,信息推广的软件或者平台
- 05-18seo积分系统,seo评分
- 05-17广州seo招聘信息,广州seo招聘信息网
- 05-17seo信息是什么,seo内容是什么意思
- 05-16如何做一个网站,如何做一个网站系统
- 05-15关于黄山seo公司的信息
- 05-14上海网站推广系统,上海网站推广服务公司
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接