資源簡介
一個學生管理系統,用C開發的,基于所學習的數據結構的鏈表知識開發。

代碼片段和文件信息
#include
#include
#include
using?namespace?std;
struct?student
{
char?name[20];
//char?*name1;
int?num;
char?sex;
float?score;
struct?student?*next;
};
int?n;
void?main()
{
struct?student?*head?=?NULL;
struct?student?*pb1*pbb;
struct?student?*?creat(struct?student*headint?n);
struct?student?*?insert(struct?student*headint?n1struct?student?*q);
bool?find(struct?student?*headint?numb);
struct?student?*del(struct?student?*headint?n1);
cout<<“請輸入你想創建的鏈表的節點個數:“< cin>>n;
head?=?creat(headn);
pb1?=?head;
if(head==NULL)
cout<<“Error!“<
???for(int?i=1;i<=n;i++)
???{ cout<name<<“?“<num<<“?“<sex<<“?“<score< pb1?=?pb1->next;
}?
??? cout< pbb?=?(struct?student*)malloc(sizeof(struct?student));
gets(pbb->name);
pbb->num =?004;
pbb->sex?=?‘F‘;
pbb->score?=?100;
pb1=?insert(head2pbb);
???
do{
cout<name<<“?“<num<<“?“<sex<<“?“<score< pb1?=?pb1->next;
}while(pb1->next!=NULL);
cout<name<<“?“<num<<“?“<sex<<“?“<score< cout< ????pb1?=?del(head2);
do{
cout<name<<“?“<num<<“?“<sex<<“?“<score< pb1?=?pb1->next;
}while(pb1->next!=NULL);
cout<name<<“?“<num<<“?“<sex<<“?“<score< cout<<“現在查找“< if(find(head123))
cout<<“找到!“< else
cout<<“沒找到!“<
}
struct?student?*creat(struct?student?*?headint?n)
{
struct?student?*pf*pb;
for(int?i=1;i<=n;i++)
{
pb?=?(struct?student?*)malloc(sizeof(struct?student));
cout<<“輸入姓名:“< cin>>pb->name;
cout<<“輸入學號:“< cin>>pb->num;
cout<<“輸入性別和分數“< cin>>pb->sex>>pb->score;
if(i==1)
{
?head?=?pb;
?pf??=?pb;
?pf?->next?=?NULL;
}
else
{
pf->next?=?pb;
pf?=?pb;
pf->next?=?NULL;
}
}
return?(head);
}
struct?student?*?insert(struct?student*headint?n1struct?student?*q)
{
struct?student?*pf;
pf?=?head;
if(n1==1)
{
q->next?=?head;
head?=?q;
}
else?if(n1>1?&&?n1<=n)
{
for(int?i=1;i {
pf?=?pf->next;
}
q->next?=?pf->next;
pf->next?=?q;
}
if(n1==n+1)
{
q->next=NULL;
for(int?j=1;j {
pf?=?pf->next;
}
q?=?pf->next;
}
return?head;
}
struct?student?*del(struct?student?*headint?n1)
{
struct?student?*pb*pf;
pf?=head;
if(n1?==?1)
{
head?=?head->next;
}
else?if(n1>1&&n1 {
for(int?j=1;j {
pf?=?pf->next;
}
pb?=?pf->next;
pf->next?=?pb->next;
}
if(n1==?n)
{
pf?->next=NULL;
}
??????return?head;
}
bool?find(struct?student?*headint?numb)
{
struct?student?*pb;
pb?=?head;
for(int?i=1;i<=n;i++)
{
if(pb->num==numb)
{
return?true;
}
pb=pb->next;
}
return?false;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????553023??2010-06-28?16:46??lianbiao\Debug\lianbiao.exe
?????文件?????789708??2010-06-28?16:46??lianbiao\Debug\lianbiao.ilk
?????文件?????268747??2010-06-28?16:46??lianbiao\Debug\lianbiao.obj
?????文件????2064500??2010-06-28?11:54??lianbiao\Debug\lianbiao.pch
?????文件????1098752??2010-06-28?16:45??lianbiao\Debug\lianbiao.pdb
?????文件??????82944??2010-06-28?16:46??lianbiao\Debug\vc60.idb
?????文件?????118784??2010-06-28?16:45??lianbiao\Debug\vc60.pdb
?????文件???????3002??2010-06-28?16:47??lianbiao\lianbiao.cpp
?????文件???????4302??2010-06-28?11:59??lianbiao\lianbiao.dsp
?????文件????????897??2010-06-28?16:46??lianbiao\lianbiao.plg
?????文件??????????0??2010-06-28?10:57??lianbiao\shishi.cpp
?????目錄??????????0??2010-06-28?20:27??lianbiao\Debug
?????目錄??????????0??2010-06-28?20:27??lianbiao
-----------?---------??----------?-----??----
??????????????4984659????????????????????13
- 上一篇:pfx證書工具
- 下一篇:retro_snake.c
評論
共有 條評論