91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

數據結構課程設計,用哈弗曼函數實現,并保存在文件中,讀取文件中信息,實現最短路徑,最少花費的算法,有飛機和列車兩種方式的查詢

資源截圖

代碼片段和文件信息

#define?MAX_VERTEX_NUM?18
#define?NULL?0
#define?MAX_ARC_SIZE?100
#define?MAX_ROUTE_NUM?5
#include“stdio.h“
#include“stdlib.h“
#include“string.h“
#define?False?0
#define?True?1
#define?INFINITY?10000
typedef?struct
{
?int?number;
?float?expenditure;
?int?begintime[2];
?int?arrivetime[2];
}Vehide;
typedef?struct
{
?Vehide?stata[MAX_ROUTE_NUM];
?int?last;
}infolist;
typedef?struct?ArcNode
{
?int?adjvex;
?struct?ArcNode?*nextarc;
?infolist?info;
}ArcNode;
typedef?struct?VNode
{
?char?cityname[10];
?ArcNode?*planefirstarc*trainfirstarc;
}VNodeAdjList[MAX_VERTEX_NUM];
typedef?struct
{
?AdjList?vertices;
?int?vexnumplanearcnumtrainarcnum;
}ALGraph;
typedef?struct?Node
{
?int?adjvex;
?int?route;
?struct?Node?*next;
}Node;
typedef?struct?QNode
{
?int?adjvex;
?struct?QNode?*next;
}QNode;
typedef?struct
{
?QNode?*front;
?QNode?*rear;
}linkQueue;
typedef?struct?TimeNode
{
?int?adjvex;
?int?route;
?int?begintime[2];
?int?arrivetime[2];
?struct?TimeNode?*child[MAX_ROUTE_NUM];
}TimeNode*TimeTree;
struct?arc
{
?int?co;
?char?vt[10];
?char?vh[10];
?int?bt[2];
?int?at[2];
?float?mo;
}a[MAX_ARC_SIZE];
char?city[MAX_VERTEX_NUM][10];
int?TTime[2];
int?time[2];
int?time1[2];
int?time2[2];
int?c[MAX_VERTEX_NUM];
int?d[MAX_VERTEX_NUM];

createcityfile()?????/*創建城市名稱文檔*/
{int?i=0;
?int?j;
?char?flag=‘y‘;
?FILE?*fp;
?printf(“\n請輸入城市名稱的信息:\n“);
?while(flag==‘y‘||flag==‘Y‘)
?{printf(“城市名稱:“);
??gets(city[i]);
??i++;
??printf(“繼續輸入?(Y/N)“);
??scanf(“%c“&flag);
??getchar();
?}
?printf(“\n“);
?if((fp=fopen(“city.txt““wb+“))==NULL)
?{printf(“無法打開文件!\n“);
??return;
?}
?for(j=0;j??fprintf(fp“%10s“city[j]);
?fclose(fp);
}
createplanefile()????/*創建飛機航班文檔*/
{int?codebt[2]at[2];
?float?money;
?int?i;
?int?count;
?char?vt[10]vh[10]flag;
?FILE?*fp;
?flag=‘y‘;
?count=0;
?while(flag==‘Y‘||flag==‘y‘)
?{printf(“請輸入飛機航班的信息:\n“);
??printf(“飛機航班編號:“);
??scanf(“%d“&code);
??getchar();
??printf(“起始城市:“);
??gets(vt);
??printf(“目的城市:“);
??gets(vh);
??printf(“航班費用:“);
??scanf(“%f“&money);
??getchar();
??printf(“起飛時間:“);
??scanf(“%d:%d“&bt[0]&bt[1]);
??getchar();
??while(bt[0]<0||bt[0]>=24||bt[1]<0||bt[1]>=60)
??{printf(“\n時間輸入有誤,請重新輸入\n“);
???scanf(“%d:%d“&bt[0]&bt[1]);
???getchar();
??}
??printf(“到達時間:“);
??scanf(“%d:%d“&at[0]&at[1]);
??getchar();
??while(at[0]<0||at[0]>=24||at[1]<0||at[1]>=60)
??{printf(“\n時間輸入有誤,請重新輸入\n“);
???scanf(“%d:%d“&at[0]&at[1]);
???getchar();
??}
??a[count].co=code;
??strcpy(a[count].vtvt);
??strcpy(a[count].vhvh);
??a[count].bt[0]=bt[0];
??a[count].bt[1]=bt[1];
??a[count].at[0]=at[0];
??a[count].at[1]=at[1];
??a[count].mo=money;
??count++;
??printf(“繼續輸入?(Y/N)“);
??scanf(“%c“&flag);
??getchar();
??printf(“\n“);
?}
?if((fp=fopen(“plane.txt““wb+“))==NULL)
??printf(“\n無法打開文件!\n“);
?fprintf(fp“%d“count);
?for(i=0;i??if(fwrite(&a[i]sizeof(struct?arc)1fp)!=1)
???print

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2010-12-02?17:06??交通咨詢系統\
?????文件???????41210??2010-10-12?10:46??交通咨詢系統\交通咨詢系統.cpp

評論

共有 條評論