鍊錶實現簡單學生資訊管理

2021-08-09 17:09:48 字數 1819 閱讀 5651

#include #include #include #define len sizeof(struct stu)

typedef long long ll;

struct stu //建立學生資訊的結構體,包含學號,姓名 ,成績三個子項

;struct stu *creat() //建立乙個鍊錶

if(tail!=null) //將尾節點的後繼設定為空

tail->next=null;

return head;

}void list(struct stu *p) //顯示煉表裡的資訊

}}void query(char c,struct stu *head) //按姓名查詢學生資訊

printf("學號:\t姓名:\t分數:\n");

printf("%lld\t%s\t%5.1lf\n",p->num,p->a,p->score);

}struct stu *delet(char c,struct stu *head)

else

if(strcmp(p->a,c)==0)

else //其他情況下將刪除掉節點的前驅節點的尾指標指向刪除節點的下乙個節點

} else }

return head;

}struct stu *add(ll k,char name,int scor,struct stu *head)

else }

if(p->num < k) //當要新增的學生學號大於表尾學號時插入到表尾 }

return head;

}struct stu *pos1(ll k, char name, int scor, int pos, struct stu *head)

p=temp=head;

if(pos==1) //當位置是1時新增到表頭

else if(pos>1 && pos<=num) //當要新增的學生位置在表中時新增到表中

}} else if(pos==num+1) //當位置在最後時新增到表尾

p->next=q; q->next=null;

strcpy(q->a,name);

q->num=k; q->score=scor;

printf("學生資訊已新增,按2檢視:") ;

} else

printf("對不起,您輸入的位置無效\n"); //其他情況下輸出位置無效的資訊

return head;

}struct stu *pos2(int n,struct stu *head) //按位置查詢學生資訊,遍歷鍊錶,當位置符合時輸出學生資訊

} if(ans==0)

printf("對不起,您輸入的位置無效\n");

}return head;

} void query2(struct stu *head) //查詢學生數量

printf("學生數量為:%d個\n",n);

} int main()

m=1;

switch(n) }

return 0;

}

學生資訊管理系統 鍊錶

實驗內容 定義乙個包含學生資訊 學號,姓名,成績 的鍊錶,使其具有如下功能 1 根據指定學生個數,逐個輸入學生資訊 2 逐個顯示學生表中所有學生的相關資訊 3 根據姓名進行查詢,返回此學生的學號和成績 4 根據指定的位置可返回相應的學生資訊 學號,姓名,成績 5 給定乙個學生資訊,插入到表中指定的位...

學生資訊管理表

建立表資料庫命名 create database if not exists xueshengbiao default charset utf8 use xueshengbiao 資料庫結構表 create table xuesheng id int unsigned key auto increm...

C語言鍊錶實現簡單的學生資訊管理系統

第一次寫部落格,今天學習了c語言鍊錶的相關知識,自己實現了乙個很簡單的學生成績管理系統,同時也溫習了一下多檔案程式設計,想和大家分享一下自己從中的一些經驗和感受。標頭檔案包含結構體的定義 ifndef m 使用條件編譯來避免重複包含 define m struct student endif typ...