公交线路查询代码(公交查询系统代码)
admin 发布:2022-12-19 05:51 102
今天给各位分享公交线路查询代码的知识,其中也会对公交查询系统代码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
- 1、基于android的手机公交查询的代码,最好有数据库和文本两种存储方式,还有可以显示查询所在地的地图
- 2、可以给我一个vb+access的公交查询系统的代码么?输入站点能够查询到相应线路的就可以了
- 3、求公交线路查询系统的c语言程序
- 4、求大神发一个c语言写的代码 公交路线的查询 具体要求【用户能够方便查询某条公交路线的详细信息。】
基于android的手机公交查询的代码,最好有数据库和文本两种存储方式,还有可以显示查询所在地的地图
. .. . . 需要用到 地图控件吗?
我看到过一个数据库文件 里面搜集了北京的所有公交路线。。
可以给我一个vb+access的公交查询系统的代码么?输入站点能够查询到相应线路的就可以了
为你提供一份针对vb+access的公交查询系统的适用于初学者的代码,
请与我们联系进一步需求,,给我留一个你的问题和Email,有机会可以帮你,绝对救急,请用BaiduHi为我留言,
此回复针对所有来访者和需求者有效,
ES:\\116D3BAF2A86DDB3111C82C95306806B
求公交线路查询系统的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。只是举个例子而已。
另外,也可以采用我上面说的多线程编程,这样更好,但是要主要互斥、加锁的问题。
由于本人是个上班的爷们,要是完成你所要的所有功能,非要写到半夜不可,所以就不给你多弄了,你自己学者弄吧。
公交线路查询代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于公交查询系统代码、公交线路查询代码的信息别忘了在本站进行查找喔。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
相关推荐
- 05-18seo网站排名查询,seo 网站排名
- 05-18百度seo关键词排名查询,seo关键词优化
- 05-18关键词排名提升查询,关键词排名查询工具有哪些
- 05-17爱站关键词挖掘查询工具,关键词爱站网关键词挖掘工具
- 05-16域名查询ip,域名查询
- 05-16域名网站查询,520113子域名网站查询
- 05-15百度代理公司查询,百度代理公司怎么样
- 05-15百度收录量查询,百度收录查询api
- 05-15站长工具外链查询,站长工具接口
- 05-14百度代理公司查询,百度授权代理查询
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接