珠海服务好的网站建设,html网站制作答辩问题,重庆企业网站开发方案,卓博人才网东莞招聘网学生记录管理系统 1--添加 2--删除 3--查询#xff1a;按姓名 4--查询#xff1a;按班级 5--查询#xff1a;按学号 0--退出 请选择操作序号(0—5):1 请输入新学生的学号:1 请输入新学生的… 学生记录管理系统 1--添加 2--删除 3--查询按姓名 4--查询按班级 5--查询按学号 0--退出 请选择操作序号(0—5):1 请输入新学生的学号:1 请输入新学生的姓名:1 请输入新学生的班级:1 请输入新学生的性别:1 请输入新学生的出生日期:1 请输入新学生的家庭住址:1 成功加入一条记录 学生记录管理系统 1--添加 2--删除 3--查询按姓名 4--查询按班级 5--查询按学号 0--退出 请选择操作序号(0—5):3 请输入要查找记录的姓名:1 1 1 1 1 1 1 查找完毕 学生记录管理系统 1--添加 2--删除 3--查询按姓名 4--查询按班级 5--查询按学号 0--退出 请选择操作序号(0—5):1 请输入新学生的学号:1 此学号已经存在不可以使用。 学生记录管理系统 1--添加 2--删除 3--查询按姓名 4--查询按班级 5--查询按学号 0--退出 请选择操作序号(0—5):1 请输入新学生的学号:2 请输入新学生的姓名:1 请输入新学生的班级:1 请输入新学生的性别:1 请输入新学生的出生日期:1 请输入新学生的家庭住址:1 成功加入一条记录 学生记录管理系统 1--添加 2--删除 3--查询按姓名 4--查询按班级 5--查询按学号 0--退出 请选择操作序号(0—5):3 请输入要查找记录的姓名:1 1 1 1 1 1 1 2 1 1 1 1 1 查找完毕 学生记录管理系统 1--添加 2--删除 3--查询按姓名 4--查询按班级 5--查询按学号 0--退出 请选择操作序号(0—5):2 请输入要删记录的学号:3 没有查到相关信息。 学生记录管理系统 1--添加 2--删除 3--查询按姓名 4--查询按班级 5--查询按学号 0--退出 请选择操作序号(0—5):2 请输入要删记录的学号:2 要删除的记录信息是: 2 1 1 1 1 1 成功删除一条记录 学生记录管理系统 1--添加 2--删除 3--查询按姓名 4--查询按班级 5--查询按学号 0--退出 请选择操作序号(0—5):4 请输入要查找记录的班级(1 2 3):1 1 1 1 1 1 1 查找完毕 学生记录管理系统 1--添加 2--删除 3--查询按姓名 4--查询按班级 5--查询按学号 0--退出 请选择操作序号(0—5):0 #include stdio.h
#include stdlib.h
#include string.h
#define LINE
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define OVERFLOW -2typedef int Status; //状态 比如找到或没找到插入成功或不成功typedef struct stu {int no; //学号char name[20]; //姓名int clas; //班级char sex[6]; //性别int birth; //出生日期 20201011char address[50]; //住址
} stu_t;typedef struct {stu_t* elem;int length;int listsize;
} SqList;
SqList L; //全局变量//构造一个空的线性表。
void InitList() {L.elem (stu_t*)malloc(3 * 3 * 40 * sizeof(stu_t));if (!L.elem)exit(OVERFLOW);L.length 0;L.listsize 3 * 3 * 40;
}void DestroyList() { /* 操作结果销毁顺序线性表L */free(L.elem);L.elem NULL;L.length 0;L.listsize 0;
}int ListFind(int no) {//根据学号查找记录是否存在 没找到返回-1int i;for (i 0; i L.length; i) {if (L.elem[i].no no)return i;}return -1;
}void PrintOne(stu_t s) {//显示一条学生记录printf(%d\t %s\t %d\t %s\t %d\t %s\n, s.no, s.name, s.clas, s.sex,s.birth, s.address);
}void FindStudent(const char* szName) {//根据姓名查找记录是否存在没找到返回-1int i;int pos -1;for (i 0; i L.length; i) {if (strcmp(L.elem[i].name, szName) 0) {pos i;PrintOne(L.elem[pos]);}}if (pos -1)puts(没有查到相关信息。);elseputs(查找完毕);
}void FindStudentByClas(const int clas) {//根据班级查找记录是否存在没找到返回-1int i;int pos -1;for (i 0; i L.length; i) {if (L.elem[i].clas clas) {pos i;PrintOne(L.elem[pos]);}}if (pos -1)puts(没有查到相关信息。);elseputs(查找完毕);
}void ListPush_back() {//表后加入新记录stu_t s;int pos;printf(请输入新学生的学号:);scanf(%d, s.no);pos ListFind(s.no);if (pos ! -1) {puts(此学号已经存在不可以使用。);return;}printf(请输入新学生的姓名:);scanf(%s, s.name);printf(请输入新学生的班级:);scanf(%d, s.clas);printf(请输入新学生的性别:);scanf(%s, s.sex);printf(请输入新学生的出生日期:);scanf(%d, s.birth);printf(请输入新学生的家庭住址:);scanf(%s, s.address);L.elem[L.length] s;puts(成功加入一条记录);
}void ListDel(int no) {int pos ListFind(no);int i;if (pos -1)puts(没有查到相关信息。);else {puts(要删除的记录信息是:);PrintOne(L.elem[pos]);for (i pos; i L.length - 1; i)L.elem[i] L.elem[i 1];L.length - 1;puts(成功删除一条记录);}
}
void FindStudentByNo(int no) {int pos ListFind(no);if (pos -1)puts(没有查到相关信息。);else {PrintOne(L.elem[pos]);puts(查找完毕);}
}unsigned menu() {unsigned a;printf(\n\n\t\t学生记录管理系统\n\n);printf(\t\t1--添加\n);printf(\t\t2--删除\n);printf(\t\t3--查询按姓名\n);printf(\t\t4--查询按班级\n);printf(\t\t5--查询按学号\n);printf(\t\t0--退出\n);printf(请选择操作序号(0—5):);scanf(%d, a); /*选择操作项*/while (a 0 || a 5) {printf(输入错误,请重新选择操作序号(0—5):);scanf(%d, a);}return a;
}int main() {unsigned select;int no;char name[20];int cls;InitList(); //初始化表while (1) {select menu();switch (select) {case 1:ListPush_back();break;case 2:printf(请输入要删记录的学号:);scanf(%d, no);ListDel(no);break;case 3:printf(请输入要查找记录的姓名:);scanf(%s, name);FindStudent(name);break;case 4:printf(请输入要查找记录的班级(1 2 3):);scanf(%d, cls);FindStudentByClas(cls);break;case 5:printf(请输入要查找记录的学号:);scanf(%d, no);FindStudentByNo(no);break;case 0:DestroyList(); //程序退出之前销毁表puts(程序已经结束退出);return 0;}puts(LINE);} return 0;
}