簡介:並未封裝成類,功能也僅實現了增量改查。資料為txt,格式:學號(long)姓名(string)總分(int)
學生資訊結構體
struct student ;
節點結構體
讀取data.txt中獲取資料struct node
};
輸出全部資訊node* readinformation(node* root)
q->next = nullptr;
delete p;
p = nullptr;
in.close();
return root;//返回首指標
}
四個基本功能:增刪改查void print(node* root)
cout << endl;
}
node* add(node* root, const student& stu)
刪刪除:
改修改://遍歷 刪除stu對應節點,然後返回頭指標
node* delete(node* root, const student& stu)
node* q = root;
node* p = q->next;
//檢查第乙個
if (q->data == stu)
while (p)
} cout << "no such information to delete.\n";
return root;
}
找://找到index:從0開始(並非id) 對應的節點,輸入修改後的資訊,修改,然後返回頭指標
void modify(node* root, const int& index)
node* p = root;
int i(0);
while (p)
else return;
} p = p->next;
++i;
} cout << "the index:" << index << " is too big.\n"
<< "there are " << i+1 << " students.\n";
}
main.cpp中:node* find(node* root,const int& cho)
long id;
string name;
int sco1, sco2;
node* p = nullptr;
switch (cho)
return nullptr;
}node* findbyid(node* root,const long& id)
p = p->next;
} return nullptr;
}node* findbyname(node* root,const string& name)
p = p->next;
} return res;
}node* findbyscore(node* root,const int& sco1,const int& sco2)
node* p = root;
int count(0);
node* res = nullptr;
while (p)
p = p->next;
} return res;
}
獨特之處:檢測的id是否已存在,存在輸入資訊無效,必須保證學號唯一#include "node.h"
node* link=nullptr;
int main()
int cho;
int cho2;
dolink = add(link, s);
break;
case 2:
cout << "information:";
cin >> s.m_id >> s.m_name >> s.m_score;
link = delete(link, s);
break;
case 3:
cout << "index:";
cin >> index;
modify(link, index);
break;
case 4:
cout << "1.find by id\n"
<< "2.find by name\n"
<< "3.find by score's range\n"
<< "enter:";
cin >> cho2;
find(link, cho2);
cout << endl;
break;
case 5:
print(link);
break;
} } while (cho);
system("pause");
return 0;
}
bool isunique(node* root, const long& id)
p = p->next;
} return true;
}
執行截圖:
![](https://pic.w3help.cc/32f/67a2a02f38d53487b9304327b84ef.jpeg)
c 實現學生成績管理
include include include include include struct score void main printf all the score bellow n printf id t語文 t英語 t數學 n for i 0 i int max 0 int m 0 for i...
C語言巢狀鍊錶實現學生成績管理系統
鍊錶a,每個節點存放乙個新的鍊錶b1,b2,b3,b4,b5的頭結點。場景 乙個年級,相當鍊錶a 該年級5個班,每個班5個人,相當於鍊錶b1 b5 做乙個學生成績管理系統 學生成績有語文 數學 英語 功能 錄入成績 找三科總分的最高分 最低分 算出平均分 鍊錶是一種常見的基礎資料結構,結構體指標在這...
順序表實現學生成績操作
標頭檔案 ifndef seqlist h define seqlist h const int maxsize 100 class seqlist seqlist int a,int n seqlist void insert int i,int x 在表中第i個位置插入值x為的元素 int de...