阿荣所做的第一个项目
-`
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <conio.h>
#include <ctype.h>
#include "Book.h"
int main()
{
int w;
int X=0;
char code;
char choice, item;
int pass,x,y;
PERSON person,other;
BOOK book ,bk;
char filename[100]="MyFile.txt";
char Filename[100]="temp.txt";
BookCreate(&book);
BookCreate(&bk);
BookRead(filename,&book);
CodeGet(&other);
printf("Tips -- %s --\n",other.code);
printf("\n ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n");
printf(" ★ 学 生 成 绩 管 理 系 统 ★\n");
printf(" ★ ★\n");
printf(" ★ 请 输 入 管 理 员 密 码 ★\n");
printf(" ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\n");
printf("\n 请输入密码:");
CodeInput(person.code);
// CodePut(&person);
CodeGet(&other);
// printf("%d",other.code);
x=PersonCode(other.code,person.code);
if(x)
{
// system("cls");
printf("\n ----选择修改密码---1 ---选择进入学生成绩管理系统---2 ---选择退出---3\n");
scanf(" %d",&y);
while((y!=1)&&(y!=2)&&(y!=3))
{
// system("cls");
while(getchar()!='\n');
printf("\n ------输入错误 请重新输入------ \n");
scanf(" %d",&y);
}
while(y!=3)
{
int n=0;
// system("cls");
if(y==1)
{
printf(" 请输入新密码:");
// while(getchar()!='\n');
CodeInput(person.code);
CodePut(&person);
system("cls");
CodeGet(&other);
printf(" \n 您的新密码为: ");
printf("%s\n",other.code);
printf("\n -----请妥善保管----- \n");
getch();
}
else if(y==2)
{
int p;
do
{
system("cls");
printf(" \n");
printf(" ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n");
printf(" ☆ ☆\n");
printf(" ☆ 学 生 成 绩 管 理 系 统 ☆\n");
printf(" ☆ ☆\n");
printf(" ☆ < A-添加 S-显示 F-查找 > ☆\n");
printf(" ☆ < M-修改 D-删除 X-排名 > ☆\n");
printf(" ☆ < T-统计 C-班级 Q-退出 > ☆\n");
printf(" ☆ < > ☆\n");
printf(" ☆ < H-说明书 > ☆\n");
printf(" ☆ ▁▂▃▄▅▆▇███▇▆▅▄▃▂▁ ☆\n");
printf(" ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n");
scanf(" %c",&choice);
choice = toupper(choice);
switch (choice)
{
case 'H':
PersonBook();
printf("请 您 按 任 意 键 退 出 说 明 书 \n");
getch();
break;
case 'A':
item=SelectIn();
w=item;
if(item!=0)
{
if(item==4)
{
SelectALL();
printf("添加\n");
PersonInput(&person);
BookAppend(&book, &person);
}
else
{
BookIn(&book,w);
}
}
// SelectALL();
// printf("添加\n");
// PersonInput(&person);
// BookAppend(&book, &person);
getch();
break ;
case 'F':
printf("查找: ");
putchar('\n');
printf("请输入查找元素\n");
item=SelectCol();
putchar('\n');
while(item!=0)
{
while(getchar()!='\n');
PersonInput(&person);
p=BookFind(&book,&person);
SelectALL();
if( p >= 0 )
{
BookOutputperson(&book , p);
}
else
{
printf("很抱歉 未找到您所要的信息!\n");
}
putchar('\n');
item=SelectCol();
putchar('\n');
}
printf("请 您 按 任 意 键 退 出 菜 单");
getch();
break;
case 'M':
printf("修改\n");
printf("查找: ");
item= SelectCol();
putchar('\n');
while(item!=0)
{
while(getchar()!='\n');
PersonInput(&person);
p=BookFind(&book,&person);
SelectALL();
if(p>=0)
{
BookOutputperson(&book,p);
printf("修改: ");
item= SelectCol();
while(item != 0 )
{
while(getchar()!='\n');
BookInputPerson(&book,p);
printf(" ---------修改成功!--------\n");
putchar('\n');
item= SelectCol();
}
printf(" ---------您已退出子菜单--------");
}
else
{
printf("-------很抱歉 输入错误 请重新输入!------- \n");
getch();
}
putchar('\n');
item= SelectCol();
}
printf("-----请 您 按 任 意 键 退 出 菜 单-----");
getch();
break;
case 'D':
printf("删除: ");
putchar('\n');
printf("请输入查找元素\n");
item=SelectCol();
putchar('\n');
while(item!=0)
{
while(getchar()!='\n');
PersonInput(&person);
p=BookFind(&book,&person);
SelectALL();
if( p >= 0 )
{
BookOutputperson(&book , p);
putchar('\n') ;
Bookdelete(&book,p);
}
else
{
printf("很抱歉 不存在该学生成绩!\n");
}
putchar('\n');
item=SelectCol();
putchar('\n');
}
printf("请 您 按 任 意 键 退 出 菜 单");
getch();
break;
case 'X':
printf("查看排名: \n");
item=SelectRank();
while(item!=0)
{
putchar('\n');
BookRank(&book);
BookOutput(&book);
putchar('\n');
item=SelectRank();
}
putchar('\n');
printf("请 您 按 任 意 键 退 出 菜 单");
getch();
break;
case 'S':
printf("显示\n");
item = SelectCol();
if(item!=0)
{
BookSort(&book);
BookOutput(&book);
}
putchar('\n');
printf("请 您 按 任 意 键 退 出 菜 单");
getch();
break;
case 'T':
printf("由系统分析可知: \n\n");
item=SelectPass();
while(item!=0)
{
putchar('\n');
BookPass(&book);
putchar('\n');
item=SelectPass();
}
putchar('\n');
printf("请 您 按 任 意 键 退 出 菜 单");
getch();
break;
case 'C':
printf("分班成绩: \n\n");
printf("选择按什么成绩排名: \n");
item=SelectRank();
while(item!=0)
{
putchar('\n');
BookRank(&book);
BookClass(&book,&bk);
putchar('\n');
item=SelectRank();
}
putchar('\n');
printf("请 您 按 任 意 键 退 出 菜 单");
getch();
break;
case 'Q':
n=1;
break;
default :
printf("错误的选项!\n");
}
}
while(choice != 'Q');
}
system("cls");
if(n==1)
{
printf("\n ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n ") ;
printf(" ☆ ☆") ;
printf("\n ☆ ---------您已成功退出学生成绩管理系统--------- ☆\n") ;
printf(" ☆ ☆") ;
printf("\n ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n ") ;
}
if(n==0)
{
printf("\n ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n ") ;
printf(" ☆ ☆") ;
printf("\n ☆ ---------密码修改成功--------- ☆\n") ;
printf(" ☆ ☆") ;
printf("\n ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n ") ;
}
printf("\n ---------- 您 可 以 进 行 以 下 操 作 ---------- \n");
printf("\n 选择修改密码---1 选择进入学生成绩管理系统---2 选择退出---3\n");
scanf(" %d",&y);
}
printf("\n -------------------欢迎下次使用-------------------\n");
}
else
{
printf("\n ---------------请使用正确密码重新登陆程序--------------\n");
return 0;
}
BookWrite(filename,&book);
BookDestroy(&book);
return 0;
}