/*所使用的標頭檔案*/
#include
#include
#include
/*所呼叫的函式*/
struct link_node *creat(struct link_node *head); //建立新結點
int count_node(struct link_node *head); //結點計數
void delete_node_num(struct link_node *head); //刪除第某個結點
//void delete_node_data(struct link_node *head); //按資料刪除結點
void cut_node_in(struct link_node *head); //插入結點
void display_node(struct link_node *head); //顯示當前的結點內容
void fun(); /*綜合功能函式*/
/*結構體*/
struct link_node
;/*主函式*/
int main()
else
system("pause");
return0;}
/*綜合功能函式*/
void fun()
system("pause");
system("cls");
break;
case
1: delete_node_num(head);
system("cls");
break;
case
2: cut_node_in(head);
system("pause");
system("cls");
break;
case
3: system("cls");
display_node(head);
system("pause");
system("cls");
break;
case
4: system("pause");
system("cls");
break;
case
5: system("pause");
system("cls");
break;
case
6: system("pause");
system("cls");
break;
case
7: system("pause");
system("cls");
break;
case
8: system("pause");
system("cls");
break;
case
9: system("cls");
system ("pause");
exit(0);}}
}/*建立新的結點*/
struct link_node *creat(struct link_node *head)
else
p2->next = p1;
p1->next = null;
printf("請輸入學號:");
scanf(" %d",&i); //%d前加空格
p1->id = i;
getchar();
printf("請輸入姓名:");
gets(p1->name);
printf("請輸入數學成績:");
scanf(" %f",&score1); //%d前加空格
p1->shuxue = score1;
printf("請輸入語文成績:");
scanf(" %f",&score2); //%d前加空格
p1->yuwen = score2;
printf("請輸入英語成績:");
scanf(" %f",&score3); //%d前加空格
p1->yingyu = score3;
}return head;
}/*結點計數*/
int count_node(struct link_node *head)
while(p->next != null); //直到指標指向最後乙個結點時,停止移動
return i; //返回結點個數給函式
}/*刪除第某個結點*/
void delete_node_num(struct link_node *head)
else
if(i >= count) //所要刪除的結點數不可以大於鍊錶的長度
else
if(i == count) //若刪除的是尾結點,則將倒數第二個的 next 賦值為 null
p2 = head;
while((p2->next)!=p1)
p2->next = null;
free(p1); //刪除結點後,釋放之前所占用的記憶體
}else
//所刪除的結點在鍊錶中(非首非尾)
p2 = p1->next;
p1->next = p2->next;
free(p2); //刪除結點後,釋放之前所占用的記憶體
}printf("操作成功!!\n");
display_node(head);
system("pause");
}/*按資料刪除結點*/
//功能未建設完全,存在bug
void delete_node_data(struct link_node *head)
p2 = p1->next;
while(p2->next != null)
}if(i != num)
p1->next = p2->next;
free(p2); //結點刪除後要釋放掉所刪除結點占用的記憶體空間,達到節約記憶體的目的
}/*插入結點*/
void cut_node_in(struct link_node *head)
else
else
if(n > count)
for(i = 0; i <= count; )
else
}printf("操作成功!!\n");
display_node(head);
}}/*顯示當前的結點內容*/
void display_node(struct link_node *head)
else
if( p->next == null)
else
while(p -> next != null);
}}
C語言巢狀鍊錶實現學生成績管理系統
鍊錶a,每個節點存放乙個新的鍊錶b1,b2,b3,b4,b5的頭結點。場景 乙個年級,相當鍊錶a 該年級5個班,每個班5個人,相當於鍊錶b1 b5 做乙個學生成績管理系統 學生成績有語文 數學 英語 功能 錄入成績 找三科總分的最高分 最低分 算出平均分 鍊錶是一種常見的基礎資料結構,結構體指標在這...
學生成績管理系統 C 實現
主要實現以下功能 1 新增學生 2 查詢學生 3 刪除學生 4 修改學生 5 重新排序 6 顯示全部 7 退出。c include include include include 用到system include using namespace std const short max size 50...
學生成績管理系統
include include include define n 50 定義符號常量,代表學生人數最大值 int count 0 全域性變數,用於記錄陣列的當前位置 struct student 定義結構體型別,代表學生資訊 void input struct student arr 函式宣告,輸入...