xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 10KB
    文件類型: .cpp
    金幣: 1
    下載: 0 次
    發布日期: 2021-05-27
  • 語言: C/C++
  • 標簽: 數據結構??

資源簡介

實現一個學生管理系統,即定義一個包含學生信息(學號,姓名,成績)的順序表,可以不考慮重名的情況,系統包含以下功能: (1) 根據指定學生個數,逐個輸入學生信息; (2) 逐個顯示學生表中所有學生的相關信息; (3) 給定一個學生信息,插入到表中指定的位置; (4) 刪除指定位置的學生記錄; (5) 統計表中學生個數; (6) 利用直接插入排序或者折半插入排序按照姓名進行排序; (7) 利用快速排序按照學號進行排序; (8) 根據姓名進行折半查找,要求使用遞歸算法實現,成功返回此學生的學號和成績; (9) 根據學號進行折半查找,要求使用非遞歸算法實現,成功返回此學生的姓名和成績。

資源截圖

代碼片段和文件信息

#include
#include
#include
#define?MAXSIZE?21?????//能容納的最大學生數

typedef?struct{
int?no;????//學號
char?name[30]; //姓名
double?score; //成績
}Student;

typedef??struct?{
??Student??*stu;?????//指向數據元素的基地址
??int??length;???????//線性表的當前長度???????????????????????????????????????????????????????????
?}SqList;

//錄入學生信息
void?input(SqList?&L){
cout?< int?n;
cin?>>?n;
while(n?>?20?||?n? cout?< cout?< cin?>>?n;
}
L.stu?=?new?Student[MAXSIZE];
L.length?=?n;

for(int?i?=?1?;?i?<=?n?;?i++){
cout?< cout?< cin?>>?L.stu[i].name;
cout?< cin?>>?L.stu[i].no;
cout?< cin?>>?L.stu[i].score;
}
cout?< cout?<}

void?output(SqList?L){
cout?< cout?< for(int?i?=?1?;?i?<=?L.length?;?i++){
cout?< cout?< }
cout?<}

//判斷學生學號是否相同
int?judge(int?n??SqList?L){
for(int?i?=?1?;?i?<=?L.length?;?i++){
if(n?==?L.stu[i].no)
return?1;
}
return?0;
}

//插入學生
void?insert(SqList?&L){
int?num?=?L.length;

if(num?==?MAXSIZE){
cout?< exit(1);
}

Student?s;
int?n;
cout?< cin?>>?n;
while(n??(num?+?1)){
cout?<<“對不起,輸入的位置有誤,請重新輸入!“< cout?< cin?>>?n;
}

cout?< cin?>>?s.no;
int?flag1?=?judge(s.no??L);
while(flag1){
cout?< cout?< cin?>>?s.no;
flag1?=?judge(s.no??L);
}
cout?< cin?>>?s.name;
cout?< cin?>>?s.score;

for(int?i?=?num?;?i?>=?n?;?i--)
L.stu[i?+?1]?=?L.stu[i];
L.stu[n]?=?s;
L.length++;
}

//刪除學生
void?deletestu(SqList?&L){
int?num?=?L.length;
if(num?==?0){
cout?< exit(1);
}
int?n;
cout?< cin?>>?n;
while(n??num){
cout?<<“對不起,刪除的位置有誤,請重新輸入!“< cout?< cin?>>?n;
}

char?ch;
cout?< cout?< cin?>>?ch;
while(ch?!=?‘Y‘?&&?ch?!=?‘y‘?&&?ch?!=?‘N‘?&&?ch?!=?‘n‘){
cout?< cout?< cin?>>?ch;
}
if(ch?==?‘Y‘?||?ch?==?‘y‘){
for(int?i?=?n;?i?<=?num;?i++)
L.stu[i]?=?L.stu[i?+?1];
L.length--;
cout?< }
else
cout?<}

//統計表中學生的個數
void?Length(SqList?L){
cout?< cout?<}

//利用折半插入排序按照姓名進行排序
void?Sort_Name(SqList?&L){
int?len?=?L.length;
for(int?i?=?2?;?i?<=?len?;?i+

評論

共有 條評論