資源簡介
數據結構課程設計----校園導游咨詢系統
用無向網表示學校的校園景點平面圖,圖中頂點表示主要景點,
存放景點的編號、名稱、簡介等信息,圖中的邊表示景點間的道路,存放路徑長度等信息。能夠回答有關景點介紹、尋找最短路徑、用戶留下對校園、顯示校園平面圖的評價、用戶登錄等問題。

代碼片段和文件信息
#include
#include
#include
#include
#include
#include
using?namespace?std;
const?int?maxv?=?50;
const?int?inf?=?1000000;
typedef?struct{
????int?G[maxv][maxv];
????int?G1[maxv][maxv];
????int?vis[maxv];
????int?d[maxv];
????int?pre[maxv];
}Graph;
typedef?struct?LNode
{
????char?name[10];
????char?pass[10];
????struct?LNode?*next;
}?LNode*pNode;
//定義節點
int?way[maxv]?=?{0};
int?n?=?20m;
int?count1?=?0;
const?int?maxsize?=?10000;
char?mean[25][15]?=?{“““校門““教學樓““馬克思樓““超市““宿舍(40)““餐廳““菜鳥驛站““禮堂““共享單車““圖書館““養心湖“\
????????????????????“汽車站““賓館““宿舍(20)““體育館““醫院““基礎實驗大樓““銀行““公園““小吃街“};
????????????????????
pNode?createList()
{
//此函數是為了構造一個鏈表,存儲用戶信息用的。
????pNode?pHead?=?(pNode)malloc(sizeof(LNode));
????pHead->next=NULL;
//以讀的方式打開user.txt文件
????FILE?*fp?=?fopen(“D:\\user.txt““r+“);
????if(fp?==?NULL)
????{
????????printf(“文件未找到“);
????????exit(-1);
????}
//獲取鏈表入口,也就是頭結點
????pNode?cur?=?pHead;
????while(1)
????{
//從user.text循環讀入所有數據并依次存于鏈表
????????pNode?temp?=?(pNode)malloc(sizeof(LNode));
????????if(!temp)
????????????exit(-1);
????????????
//下面fscanf是從文件讀取信息,并存入節點的name變量和pass變量
????????//如果fscanf的返回值不是2,則說明后面沒有數據了,也即是錄入完畢
//檢測到錄入完畢后將分配的空間清除掉
????????if(2!=fscanf(fp“%s%s“temp->nametemp->pass))
????????{
????????????free(temp);
????????????break;
????????}
cur->next=temp;
????????cur?=?temp;
????????cur->next?=?NULL;
????}
????return?pHead;
}
//登錄函數
int?login(pNode?head)
{
????if(NULL==head->next)
????{
????????printf(“暫無用戶\n“);
????????getchar();
????????return?0;
????}
????char?name[10];
????char?pass[10];
????printf(“\t\t請輸入你的用戶名:“);
????scanf(“%s“name);
????printf(“\t\t請輸入你的密碼:“);
????scanf(“%s“pass);
????pNode?temp?=?head->next;
????while(temp)
????{
????????if(0==strcmp(temp->namename)?&&?0==strcmp(temp->passpass))
????????{
????????????printf(“\t\t成功登錄\n“);
????????????getchar();
????????????return?1;
????????}
????????temp?=?temp->next;
????}
????printf(“未找到該用戶\n“);
????getch();
????return?1;
}
//寫入txt文件,每一行存在一個用戶
void?writeToFile(pNode?head)
{
????FILE?*fw?=?fopen(“D:\\user.txt““a+“);
????pNode?temp=head->next;
????if(temp==NULL){
????????return;
????}
????while(temp){
????????fprintf(fwtemp->name);
????????fprintf(fw“\t“);
????????fprintf(fwtemp->pass);
????????fprintf(fw“\n“);
????????temp??=?temp->next;
????}
}
//注冊用戶
void?registerUser(pNode?head)
{
????pNode?temp?=?head->next;
????//當表中無用戶直接在頭結點后注冊
????if(!temp)
????{
????????temp?=?(pNode)malloc(sizeof(LNode));
????????head->next?=?temp;
????}
????else
????{
????????//表中有用戶則在最后一個節點后生成新節點
????????while(temp->next)
????????{
????????????temp?=?temp->next;
????????}
????????pNode?last?=?(pNode)malloc(sizeof(LNode));
????????temp->next?=?last;
????????temp?=?last;
????}
????printf(“\t\t請輸入你的用戶名:“);
????scanf(“%s“temp->name);
????printf(“\t\t請輸入你的密碼:“);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????25811??2020-07-03?18:09??course_design.cpp
?????文件??????962382??2020-07-04?10:20??校園導游咨詢系統論文.doc
- 上一篇:基于OpenCV的分水嶺算法實現
- 下一篇:主數據管理MDM解決方案
評論
共有 條評論