You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
2.8 KiB
133 lines
2.8 KiB
#include<stdio.h>
|
|
#include<string.h>
|
|
#include<stdlib.h>
|
|
void insert();//录入学生信息
|
|
void findCLASS();//按班级查询
|
|
void findNO();//按学号查询//
|
|
void findNAME();//按姓名查询
|
|
void money();//结账
|
|
void addstu();//添加学生
|
|
void addfile(); //添加到文件
|
|
struct time//时间结构体
|
|
{
|
|
int hour;
|
|
int min;
|
|
};
|
|
struct STUDENT//学生结构体
|
|
{
|
|
|
|
char NO[20];
|
|
char CLASS[20];
|
|
char NAME[20];
|
|
int time_hour;
|
|
int time_min;
|
|
struct time begin,end;//嵌套定义学生结构体
|
|
};
|
|
struct STUDENT stu[30];
|
|
static int i=0;
|
|
|
|
int main()//主函数
|
|
{
|
|
int i;
|
|
for(;;)
|
|
{ //主界面
|
|
printf("\t\t\t*********************\n");
|
|
printf("\t\t\t 菜单 \n");
|
|
printf("\t\t\t1 创建学生信息\n");
|
|
printf("\t\t\t2 按学号查找学生信息\n");
|
|
printf("\t\t\t3 按班级查找学生\n");
|
|
printf("\t\t\t4 按姓名查找学生\n");
|
|
printf("\t\t\t5 上机费用\n");
|
|
printf("\t\t\t6 添加学生信息\n");
|
|
printf("\t\t\t7 添加学生信息到文件\n");
|
|
printf("\t\t\t8 关闭系统");
|
|
printf("\n\n\n\t\t\t输入相应序号进行操作\n\n\t\t\t");
|
|
scanf("%d",&i);
|
|
switch(i)//选择分支结构
|
|
{
|
|
case 1:
|
|
{
|
|
system("cls");
|
|
insert();
|
|
|
|
}break;
|
|
case 2:
|
|
{
|
|
system("cls");
|
|
findNO();
|
|
}break;
|
|
case 3:
|
|
{
|
|
system("cls");
|
|
findCLASS();
|
|
} break;
|
|
case 4:
|
|
{
|
|
system("cls");
|
|
findNAME();
|
|
}break;
|
|
case 5:
|
|
{
|
|
system("cls");
|
|
money();
|
|
}break;
|
|
case 6:
|
|
{
|
|
system("cls");
|
|
addstu();
|
|
}break;
|
|
|
|
case 7:
|
|
{
|
|
system("cls");
|
|
addfile();
|
|
}break;
|
|
case 8:
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
system("pause") ;
|
|
return 0;
|
|
}
|
|
void insert()//录入
|
|
{
|
|
printf("请输入学生学号:\n");
|
|
scanf("%s",&stu[i].NO);
|
|
printf("请输入学生班级:\n");
|
|
scanf("%s",&stu[i].CLASS);
|
|
printf("请输入学生姓名:\n");
|
|
scanf("%s",&stu[i].NAME);
|
|
printf("请输入起始时间:\n");
|
|
scanf("%d:%d",&stu[i].begin.hour,&stu[i].begin.min);
|
|
i=i+1;
|
|
system("pause");
|
|
system("cls");
|
|
}
|
|
void findNO()//学号查找
|
|
{
|
|
int m;
|
|
char no[100];
|
|
printf("输入学号:");
|
|
scanf("%s",&no);
|
|
for(m=0;m<i;m++)
|
|
{
|
|
if(!strcmp(no,stu[m].NO))
|
|
{
|
|
printf("学号是:%s\n",stu[m].NO);
|
|
printf("班级是:%s\n",stu[m].CLASS);
|
|
printf("姓名是:%s\n",stu[m].NAME);
|
|
printf("起始时间是:%d:%d\n",stu[m].begin.hour,stu[m].begin.min);
|
|
|
|
|
|
}
|
|
else printf("查无此人\n");
|
|
system("pause");
|
|
system("cls");
|
|
}
|
|
|
|
} |