只建了一个模型
#include<cstdio>
#include<iostream>
#include<malloc.h>
using namespace std;
int select; //做全局变量
//主菜单
void menu();
//卡片管理
void cardManage();
//开户
void openAccount();
//食堂应用
void diningApplication();
typedef struct StudentInf{
char StudentName[20];//学生的姓名
char StudentNumber[20];//学生学号
char CardNumber[20];//学生卡号
bool state;//表示是否销户,0表示销户
double money;//校园卡中余额的多少
int key;//卡的密码
}Student;
struct Node{
Student student;
struct Node* next;
};
//创建链表
struct Node* creatList()
{
struct Node* headNode=(struct Node*)malloc(sizeof(struct Node));
headNode->next=NULL;
return headNode;
}
//创建结点
struct Node* creatNode()
{
struct Node* newNode=(struct Node*)malloc(sizeof(struct Node));
cout<<"请输入学号:";
cin>>newNode->student.StudentNumber;
cout<<"请输入姓名:";
cin>>newNode->student.StudentName;
newNode->next=NULL;
return newNode;
}
//插入节点(前插法)
void insertNode(struct Node* headNode)
{
struct Node* newNode=creatNode();
newNode->next=headNode->next;
headNode->next=newNode;
}
//主界面
void menu(){
system("cls"); //清屏
printf("\t\t**************************\n");
printf("\t\t**华中科技大学校园卡系统**\n");
cout<<"\t\t**************************"<<endl;
printf("\t\t*\t请选择\t\t *\n");
printf("\t\t* 1:卡片管理\t\t *\n");
printf("\t\t* 2:食堂应用\t\t *\n");
printf("\t\t* 3:汇总分析\t\t *\n");
printf("\t\t* 4:退出系统\t\t *\n");
cout<<"\t\t**************************"<<endl;
}
//卡片管理
void cardManage(){
system("cls"); //清屏
printf("\t\t**************************\n");
printf("\t\t*********卡片管理*********\n");
cout<<"\t\t**************************"<<endl;
printf("\t\t*请选择\t\t\t *\n");
printf("\t\t* 1:开户\t\t *\n");
printf("\t\t* 2:销户\t\t *\n");
printf("\t\t* 3:发卡\t\t *\n");
printf("\t\t* 4:挂失\t\t *\n");
printf("\t\t* 5:解挂\t\t *\n");
printf("\t\t* 6:补卡\t\t *\n");
printf("\t\t* 7:充值\t\t *\n");
printf("\t\t* 0: 返回\t\t *\n");
cout<<"\t\t**************************"<<endl;
scanf("%d",&select);
switch(select){
case 1:
system("cls");
openAccount();
break;
case 2:
break;
break;
case 3:
break;
case 4:
break;
}
}
//打印
void printList(struct Node* headNode){
struct Node* pMove=headNode->next;
while(pMove)
{
cout<<pMove->student.StudentNumber<<" ";
cout<<pMove->student.StudentName<<" "<<endl;
pMove=pMove->next;
}
}
struct Node* list=creatList();
//开户
void openAccount(){
insertNode(list);
cout<<"开户成功"<<endl;
//printList(list);
//openAccount();
}
//食堂应用
void diningApplication(){
system("cls"); //清屏
printf("\t\t**************************\n");
printf("\t\t*****华中科技大学食堂*****\n");
cout<<"\t\t**************************"<<endl;
printf("\t\t*请选择\t\t\t *\n");
printf("\t\t* 1:窗口1\t\t *\n");
printf("\t\t* 2:窗口2\t\t *\n");
printf("\t\t* 3:窗口3\t\t *\n");
printf("\t\t* 4:窗口4\t\t *\n");
printf("\t\t* 5:窗口5\t\t *\n");
printf("\t\t* 0: 返回\t\t *\n");
cout<<"\t\t**************************"<<endl;
}
int main()
{
menu();
scanf("%d",&select);
switch(select){
case 1:
system("cls");
cardManage();
break;
case 2:
diningApplication();
break;
break;
case 3:
break;
case 4:
break;
}
return 0;
}