#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#define OK 1
#define ERROR -1
#define N 10
#define OUTFORMAT "学号 姓名 性别 出生年月 英语 数据结构 总分\n"
#define FORMAT " %d %s %s %s %-5.1f %-5.1f \n"
#define DATA grade[i].STUDENTID,grade[i].name,grade[i].sex,grade[i].Date,grade[i].egrade,grade[i].data_structure,grade[i].all_grade
using namespace std;
struct stugrade {
int STUDENTID;//学号
string name[15];//姓名
string sex;//性别
string Date;
float egrade;//英语成绩
float data_structure;//数据结构成绩
float all_grade=egrade+data_structure;//总成绩
};
struct student* next;//指向下一个学生的指针
struct stugrade gra[N];
void menu1();//teacher
void menu2();//student
void input();
void insert();
int traversal();
void Search();
void modifications();
void Delete();
void sortingorder();
void menu();
void select1();//teacher
void select2();//student
// Academic Records Management System (ARMS).cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include "Academic Records Management System (ARMS).h"
void menu1()//老师菜单
{
system("cls");//清屏
int i;
for (i = 0; i <= 25; i++)
{
printf(" * ");
}
printf("\n");
printf("1,学生信息输入 2,查找学生信息\n");
printf("3,修改学生信息 4,增加学生信息\n");
printf("5,删除学生信息 6,成绩排序由高到低\n");
printf("7,遍历显示所有 8,退出系统\n");
printf(" 9,切换登陆系统 ");
printf("\n");
for (i = 0; i <= 25; i++)
{
printf(" * ");
}printf("\n");
select1();
}
void menu2()//学生菜单
{
system("cls");
int i;
for (i = 0; i <= 25; i++)
{
printf(" * ");
}
printf("\n");
printf("1,查询成绩 2,显示所有\n");
printf("3,成绩排行 4,切换登陆系统\n");
printf(" 5,退出系统 ");
printf("\n");
for (i = 0; i <= 25; i++)
{
printf(" * ");
}printf("\n");
//select2();
}
void menu()
{ int a;
printf("select");
scanf_s("%d",&a);
printf("1.teacher\n");
printf("2.student\n");
if(a=1)
menu1();
else if(a=2)
menu2();
else printf("wrong");
}
void select1()//teacher选择菜单
{
int a;
scanf_s("%d", &a);
switch (a)
{
case 1:input();
break;
case 2:Search();
break;
case 3:modifications();
break;
case 4:insert();
break;
case 5:Delete();
break;
case 6:sortingorder();
break;
case 7:traversal();
break;
case 8:printf("out"); exit(0);
break;
case 9:menu();
break;
default:printf("wrong");
}
// void select2()//选择菜单student功能
// {
// int a;
// scanf_s("%d", &a);
// if (a = 1)
// input();
// else if (a = 2)
// del();
// else if (a = 3)
// check();
// else if (a = 4)
// xiugai();
// else if (a = 5)
// paixu();
// else if (a = 6)
// charu();
// else if (a = 7)
// xianshi();
// else if (a = 8)
// tuichu();
// else if (a = 9)
// qiehuan();
//}
//菜单
void input()
{ while(N)
{
struct student* createlist()
{
struct product* head, * new, * p;
head = (struct product*)malloc(sizeof(struct student));//为新结点申请内存空间
if (head != NULL)
{
printf("please input your STUDENTID:"); scanf_s("%d", &new->STUDENTID);
printf("please input your name:"); scanf_s("%s", &new->name);
printf("please input your sex:"); scanf_s("%s", &new->sex);
printf("please input your Date:"); scanf_s("%s", &new->Date);
printf("please input your egrade:"); scanf_s("%-5.1f", &new->egrade);
printf("please input your data_structure:"); scanf_s("%-5.1f", &new->data_structure);
head->next = NULL;
p = head;
}
else
{
printf("ERROR"); exit(0);
}
}
}
/*
//申请一个单链表
STUDENT* newStudent = (STUDENT*)malloc(sizeof(STUDENT));
if (newStudent == NULL) {
// 处理内存分配失败
printf("Memory allocation failed.\n");
return;
}
int a;
printf("please input 1-5");
scanf_s("%d", &a);
while (1) {
switch (a)
{
case 1: printf("please input your name");
scanf_s("%s", grade[i].name);
break;
case 2: printf("please input your StudentID");
scanf_s("%d", grade[i].STUDENTID);
break;
case 3: printf("please input your Sex");
scanf_s("%s", grade[i].sex);
break;
case 4: printf("please input your Date");
scanf_s("%s", grade[i].Date);
break;
case 5:printf("please input your English score");
scanf_s("%5.1f", grade[i].egrade);
break;
case 6:printf("please input your data_structure score");
scanf_s("%5.1f", grade[i].data_structure);
break;
case 7:menu1();
break;
default:printf("wrong");
}
}
newStudent->next = NULL; // 初始化新节点的 next 指针
addStudent(Student);*/
}
/*
//插入
void insert(LinkList &L,int i,ElemType e)
{
p = L; j = 0;
while (p && (j < i - 1))
{
p = p->next; ++j;
}
if (!p || j > i - 1) return ERROR;
s = new LNode;
s->data = e;
s->next = p->next;
p->next = s;
return OK;
}
*/
//遍历
int traversal()
{
struct product* p;
p = head;
while (p != NULL)
{
printf("%d,",p->STUDENTID);
printf("%s",p->name);
printf("%s",p->sex);
printf("%s", p->egrade);
printf("%-5.1f",p->data_structure);
printf("%-5.1f",p->all_grade);
p = p->next;
}
}
/*
//搜索,根据学号搜索学生信息
void Search(Student* head, int StudentID)
{
Student* L = head->next;
while (L != NULL) {
if (L->StudentID == StudentID) {
return L;
}
L = L->next;
}
return NULL;
}
*/
/*
//修改
void modifications()
{
for (i = 0; i < L.length; i++)//查找
if (L.elem[i] == e) return i + 1;
printf("please modify your information");
scanf_s("%s", &STUDENTID);
scanf_s("%s", &name);
scanf_s("%s", &sex);
scanf_s("-%5.1f", &Date);
scanf_s("-%5.1f", &egrade);
scanf_s("-%5.1f", &data_structure);
return 0;
}
*/
/*
//删除
void Delete(LinkList &L,int i)
{
p = L; j = 0;
while ((p->next) && (j < i - 1))
{
p = p->next; ++j;
}
if (!(p->next) || (j > i - 1)) return ERROR;
q = p->next;
p->next = q->next;
delete q;
return OK;
}
*/
/*
//排序
void sortingorder()
{
if (grade[i].all_grade == NULL)
return ERROR;
else if (grade[i + 1].all_grade > grade[i].all_grade)
for (i = 0; i <= n; i++)
printf("-%5.1f -%5.1f", grade[i + 1].all_grade grade[i].all_grade);
else
printf("-%5.1f -%5.1f", grade[i].all_grade grade[i + 1].all_grade);
}
*/
int main()
{
printf("Welcome ");
menu();
}