-
大小: 818KB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2024-02-04
- 語言: 其他
- 標(biāo)簽:
資源簡介
數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì)----校園導(dǎo)游咨詢系統(tǒng)
用無向網(wǎng)表示學(xué)校的校園景點(diǎn)平面圖,圖中頂點(diǎn)表示主要景點(diǎn),
存放景點(diǎn)的編號(hào)、名稱、簡介等信息,圖中的邊表示景點(diǎn)間的道路,存放路徑長度等信息。能夠回答有關(guān)景點(diǎn)介紹、尋找最短路徑、用戶留下對(duì)校園、顯示校園平面圖的評(píng)價(jià)、用戶登錄等問題。

代碼片段和文件信息
#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;
//定義節(jié)點(diǎn)
int?way[maxv]?=?{0};
int?n?=?20m;
int?count1?=?0;
const?int?maxsize?=?10000;
char?mean[25][15]?=?{“““校門““教學(xué)樓““馬克思樓““超市““宿舍(40)““餐廳““菜鳥驛站““禮堂““共享單車““圖書館““養(yǎng)心湖“\
????????????????????“汽車站““賓館““宿舍(20)““體育館““醫(yī)院““基礎(chǔ)實(shí)驗(yàn)大樓““銀行““公園““小吃街“};
????????????????????
pNode?createList()
{
//此函數(shù)是為了構(gòu)造一個(gè)鏈表,存儲(chǔ)用戶信息用的。
????pNode?pHead?=?(pNode)malloc(sizeof(LNode));
????pHead->next=NULL;
//以讀的方式打開user.txt文件
????FILE?*fp?=?fopen(“D:\\user.txt““r+“);
????if(fp?==?NULL)
????{
????????printf(“文件未找到“);
????????exit(-1);
????}
//獲取鏈表入口,也就是頭結(jié)點(diǎn)
????pNode?cur?=?pHead;
????while(1)
????{
//從user.text循環(huán)讀入所有數(shù)據(jù)并依次存于鏈表
????????pNode?temp?=?(pNode)malloc(sizeof(LNode));
????????if(!temp)
????????????exit(-1);
????????????
//下面fscanf是從文件讀取信息,并存入節(jié)點(diǎn)的name變量和pass變量
????????//如果fscanf的返回值不是2,則說明后面沒有數(shù)據(jù)了,也即是錄入完畢
//檢測到錄入完畢后將分配的空間清除掉
????????if(2!=fscanf(fp“%s%s“temp->nametemp->pass))
????????{
????????????free(temp);
????????????break;
????????}
cur->next=temp;
????????cur?=?temp;
????????cur->next?=?NULL;
????}
????return?pHead;
}
//登錄函數(shù)
int?login(pNode?head)
{
????if(NULL==head->next)
????{
????????printf(“暫無用戶\n“);
????????getchar();
????????return?0;
????}
????char?name[10];
????char?pass[10];
????printf(“\t\t請(qǐng)輸入你的用戶名:“);
????scanf(“%s“name);
????printf(“\t\t請(qǐng)輸入你的密碼:“);
????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文件,每一行存在一個(gè)用戶
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;
????}
}
//注冊(cè)用戶
void?registerUser(pNode?head)
{
????pNode?temp?=?head->next;
????//當(dāng)表中無用戶直接在頭結(jié)點(diǎn)后注冊(cè)
????if(!temp)
????{
????????temp?=?(pNode)malloc(sizeof(LNode));
????????head->next?=?temp;
????}
????else
????{
????????//表中有用戶則在最后一個(gè)節(jié)點(diǎn)后生成新節(jié)點(diǎn)
????????while(temp->next)
????????{
????????????temp?=?temp->next;
????????}
????????pNode?last?=?(pNode)malloc(sizeof(LNode));
????????temp->next?=?last;
????????temp?=?last;
????}
????printf(“\t\t請(qǐng)輸入你的用戶名:“);
????scanf(“%s“temp->name);
????printf(“\t\t請(qǐng)輸入你的密碼:“);
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????25811??2020-07-03?18:09??course_design.cpp
?????文件??????962382??2020-07-04?10:20??校園導(dǎo)游咨詢系統(tǒng)論文.doc
評(píng)論
共有 條評(píng)論