鏈表實(shí)現(xiàn)學(xué)生信息菜單管理系統(tǒng)_第1頁(yè)
鏈表實(shí)現(xiàn)學(xué)生信息菜單管理系統(tǒng)_第2頁(yè)
鏈表實(shí)現(xiàn)學(xué)生信息菜單管理系統(tǒng)_第3頁(yè)
免費(fèi)預(yù)覽已結(jié)束,剩余1頁(yè)可下載查看

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、實(shí)驗(yàn)名稱(chēng):鏈表實(shí)現(xiàn)學(xué)生信息菜單管理系統(tǒng)一、實(shí)驗(yàn)?zāi)康模?、掌握順序表結(jié)構(gòu)的實(shí)現(xiàn)方式;2、掌握順序表常用算法的實(shí)現(xiàn);3、熟悉利用順序表解決問(wèn)題的一般思路;4、參照給定的順序表的程序樣例,驗(yàn)證給出的順序表的常見(jiàn)算法,領(lǐng)會(huì)順序表結(jié) 構(gòu)的優(yōu)點(diǎn)和不足。二、實(shí)驗(yàn)內(nèi)容:1、編程完成順序表的基本操作:建立、刪除、查找及顯示。2、按要求完成學(xué)生名冊(cè)管理程序的編寫(xiě)和調(diào)試。三、實(shí)驗(yàn)結(jié)果:1、創(chuàng)建:2、刪除:3、添加:4、退出:四、實(shí)驗(yàn)中遇到的問(wèn)題及解決方法:問(wèn)題一:地址傳遞出錯(cuò)解決方案:參考網(wǎng)上資料代碼。問(wèn)題二:創(chuàng)建時(shí),停止暫停解決方案: 輸入學(xué)號(hào)為零時(shí)停止輸入問(wèn)題三: 創(chuàng)建時(shí)需要學(xué)號(hào)姓名成績(jī)都為零才能停止創(chuàng)建解決方

2、案:占無(wú)解決方案五、實(shí)驗(yàn)心得體會(huì):鏈表中指針的使用要注意指針的性質(zhì),確保地址正確傳遞,要改變的值正確改變。在編程過(guò)程 中很容易出現(xiàn)地址傳遞出錯(cuò)的問(wèn)題,需要有耐心慢慢排查故障,解決故障。通過(guò)本次實(shí)驗(yàn)讓我明白了鏈表的操作使用,加深了我對(duì)鏈表的理解,同時(shí)也通過(guò)不斷地練習(xí)提 高了編程能力,鏈表的掌握對(duì)于這門(mén)課程而言十分重要,在今后的學(xué)習(xí)中,我需要更加努力, 才能更好的掌握和使用鏈表。源代碼:#include #include #define NULL 0#define LEN sizeof(struct student) struct studentint num;char name20;float

3、score; struct student *next;int n;struct student *Create()struct student *head; struct student *p1 = NULL; struct student *p2 = NULL;n = 0;p1 = (struct student *) malloc (LEN); p2 = p1;if(p1=NULL)printf (nCannt create it, try it again in a moment!n); return NULL;elsehead = NULL;printf(請(qǐng)輸入第c個(gè)學(xué)生學(xué)號(hào)姓名成績(jī)

4、:n,n+1);scanf(%d %s %f,&(p1-num),p1-name,&(p1-score); while(p1-num != 0)n += 1; if(n = 1) head = p1; p2-next = NULL; else p2-next = p1;p2 = p1;p1 = (struct student *) malloc (LEN);printf(請(qǐng)輸入第c個(gè)學(xué)生學(xué)號(hào)姓名成績(jī):n,n+1);scanf(%d %s %f,&(p1-num),p1-name,&(p1-score); p2-next = NULL;free(p1);p1 = NULL; return hea

5、d;void Print(struct student *head)struct student *p;printf (nNow , These %d records are:n, n);p = head; if(head != NULL)printf(head is %on, head);do printf (%dt%st%n, p-num, p-name, p-score); p = p-next; while (p != NULL);struct student *Del (struct student *head, int num)struct student *p1;struct s

6、tudent *p2;if (head = NULL)printf (nList is null!n); return head;p1 = head;while (p1-num != num & p1-next != NULL) p2 = p1;p1 = p1-next;if(p1-num=num)if (p1 = head)head = p1-next;elsep2-next = p1-next;free (p1);p1 = NULL;printf (ndelete %ld success!n, num); n -= 1;elseprintf (n%ld not been found!n,

7、num);return head;struct student *Insert (struct student *head, int num, struct student *node) struct student *p1;if (head = NULL) head = node;node-next = NULL;n += 1;return head;p1 = head;while(p1-num != num & p1-next != NULL) p1 = p1-next;if (p1-num=num) node-next = p1-next; p1-next = node; n += 1;

8、elseprintf (n%ld not been found!n, num);return head;int main(void)struct student *head;struct student *stu;int thenumber;int command,flag=1;while(flag)printf(1、創(chuàng)建管理系統(tǒng)n2、刪除學(xué)生信息n3、添加學(xué)生信息n4、退出n);printf(當(dāng)學(xué)號(hào) 姓名 成績(jī)都為 0 時(shí),停止創(chuàng)建 n);printf(輸入指令 :);scanf(%d,&command);switch(command)case 1:head = Create();Print(head); break;case 2:printf(nWhich one delete: ); scanf(%d,&thenumber); head = Del(head,thenumber); Print(head); break;case 3:stu = (struct student *)malloc(LEN);printf(請(qǐng)輸入第c個(gè)學(xué)生學(xué)號(hào),姓名,成績(jī):n,n+1);scanf(%d %s %f,&(stu-n

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論