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.

372 lines
7.1 KiB

6 years ago
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
6 years ago
#include <windows.h>
6 years ago
//<2F><><EFBFBD><EFBFBD><E5BAAF>
FILE *fp; //<2F>ļ<EFBFBD>ָ<EFBFBD><D6B8>
void menu();
void add();
void search();
void modify();
6 years ago
void dele();
6 years ago
void look();
void quit();
6 years ago
void enroll();
void login();
void reenroll();
void jiemian();
void ycmm();
void relogin();
int n;
int m;
int t;
int offset;
char mima_[10];
char MIMA[4]="5555";
struct manager
{
char name[10];
char password[10];
}manage[5];
6 years ago
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int main()
{
6 years ago
int a=0;
n=0;
do
{
jiemian();
getchar();
printf("\n<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>");
a=getch();
}while(a==49);
6 years ago
return 0;
}
//ͨѶ¼<D1B6><EFBFBD><E1B9B9>
struct user
{
char name[8]; //<2F><><EFBFBD><EFBFBD>
char place[15]; //<2F><><EFBFBD><EFBFBD>
char tel1[15]; //<2F>绰1
char tel2[15]; //<2F>绰2
char email[20]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}user[50];
6 years ago
void jiemian()
6 years ago
{
system("cls");
system("color f3");
int n;
printf("\n\n\n\n\n");
printf("\t\t:---------ͨѶ¼---------:\n");
6 years ago
printf("\t\t: 1.ע<><D7A2> :\n");
printf("\t\t: 2.<2E><>¼ :\n");
printf("\t\t:--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <1-2>ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--:\n\n");
6 years ago
scanf("%d",&n);
switch(n)
{
6 years ago
case 1: enroll(); break; //ע<><D7A2>
case 2: login(); break; //<2F><>¼
6 years ago
default: return;
6 years ago
}
}
//ע<><D7A2>
void enroll()
{
system("cls");
int anhao; //<2F><><EFBFBD><EFBFBD>Ա<EFBFBD>ܳ<EFBFBD>
char zhanghao[10];
char mima1[10];
char mima2[10];
//<2F><><EFBFBD><EFBFBD>Աע<D4B1><D7A2>
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>");
ycmm();
//<2F><><EFBFBD>ź˶<C5BA><CBB6><EFBFBD>ȷ
if(!strcmp(mima_,MIMA)){
fp=fopen("manager.txt","ab");
struct manager one;
printf("\n\t\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¹<EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>˺ţ<EFBFBD>");
scanf("%s",zhanghao);
printf("\n\t\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¹<EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>");
ycmm();
strcpy(mima1,mima_);
printf("\n\t\t\t<EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
ycmm();
strcpy(mima2,mima_);
if(!strcmp(mima1,mima2)){
strcpy(one.name,zhanghao);
strcpy(one.password,mima1);
fprintf(fp,"%-10s%-10s",one.name,one.password);
}
else{
fclose(fp);reenroll();return;
}
printf("\t\t\tע<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n\n");
fclose(fp);
printf("3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
Sleep(3000);
menu();
return;
}
//<2F><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD>ע<EFBFBD><D7A2>
else
printf("<EFBFBD><EFBFBD><EFBFBD>Ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n\n");reenroll();
return;
}
//<2F><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
void reenroll()
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD>밴1<EFBFBD><EFBFBD>");
if(getch()==49)
enroll();
else
jiemian();
}
//<2F><>¼
void login()
{
system("cls");
char zhanghao[20];
char mima[20];
char password2[20];
if((fp=fopen("manager.txt","rb"))==NULL){
printf("δ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>˺<EFBFBD>\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ᣬ3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
Sleep(3000);
enroll();
exit(0);
}
struct manager one;
printf("\n\t\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>˺ţ<EFBFBD>");
scanf("%s",zhanghao);
printf("\n\t\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>");
ycmm();
while(!feof(fp)){
fscanf(fp,"%s%s",one.name,one.password);
if(!strcmp(zhanghao,one.name)&&!strcmp(mima_,one.password)){
printf("\n<EFBFBD><EFBFBD>¼<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
n=1;
fclose(fp);
printf("3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
Sleep(3000);
menu();return;
}
}
printf("\t\t\t<EFBFBD><EFBFBD>¼ʧ<EFBFBD>ܣ<EFBFBD>\n\n");
fclose(fp);
relogin();
return;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
void relogin()
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>밴1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
if(getch()==49)
login();
else
jiemian();
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void ycmm()
{
int i=0;
for(;i<10;i++)
{
mima_[i]=getch();
if(mima_[i]=='\b')
{
if(i<=0)
printf(" "),i=1;
printf("\b \b");
i=i-2;
continue;
}
if(mima_[i]=='\r')
{
break;
}
printf("*");
}
mima_[i]='\0';
}
//<2F>˵<EFBFBD>
void menu()
{
int b=0;
do{
system("cls");
system("color f3");
int a;
b=0;
printf("\n\n\n\n\n");
printf("\t\t:----ͨѶ¼<D1B6><C2BC><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>----:\n");
printf("\t\t: 1:<3A>½<EFBFBD> :\n");
printf("\t\t: 2:<3A><>ѯ :\n");
printf("\t\t: 3:<3A>޸<EFBFBD> :\n");
printf("\t\t: 4:ɾ<><C9BE> :\n");
printf("\t\t: 5:<3A><><EFBFBD><EFBFBD> :\n");
printf("\t\t: 6:<3A><><EFBFBD><EFBFBD> :\n");
printf("\t\t: 7:<3A>˳<EFBFBD> :\n");
printf("\t\t:--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <1-7>ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--:\n\n");
scanf("%d",&a);
switch(a)
{
case 1: add(); break; //<2F><><EFBFBD><EFBFBD>
case 2: search(); break; //<2F><>ѯ
case 3: modify(); break; //<2F>޸<EFBFBD>
case 4: dele(); break; //ɾ<><C9BE>
case 5: look(); break; //<2F><><EFBFBD><EFBFBD>
case 6: jiemian(); break; //<2F>˳<EFBFBD>
case 7: exit(0);
default: return;
}
printf("<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>");
b=getch();
}while(b==49);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ 1.<2E>½<EFBFBD>
6 years ago
void add()
{
6 years ago
struct user one={'\0','\0','\0','\0','\0'};//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
6 years ago
system("color e3");
if((fp=fopen("user.txt","ab"))==NULL)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
exit(0);
}
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",one.name);
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",one.place);
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>");
scanf("%s",one.tel1);
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>");
scanf("%s",one.tel2);
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",one.email);
6 years ago
fprintf(fp,"%-8s%-15s%-15s%-15s%-20s\n",one.name,one.place,one.tel1,one.tel2,one.email);
6 years ago
fclose(fp);
6 years ago
printf("\n<EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD><EFBFBD><EFBFBD>\n");
}
//<2F><>ѯ 2.<2E><>ѯ
void search()
6 years ago
{
6 years ago
struct user one;
6 years ago
char namekey[8];
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",namekey);
6 years ago
if((fp=fopen("user.txt","rb"))==NULL) //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
6 years ago
{
printf("\n<EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>\n");
exit(0);
}
6 years ago
t=0;
m=0;
6 years ago
while(!feof(fp))
{
6 years ago
offset=ftell(fp);
fscanf(fp,"%s%s%s%s%s\n",one.name,one.place,one.tel1,one.tel2,one.email);
if(!strcmp(one.name,namekey)) //<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>ͬ
6 years ago
{
6 years ago
t=1;
printf("%-8s%-15s%-15s%-15s%-20s\n",one.name,one.place,one.tel1,one.tel2,one.email); //<2F><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><DABA><EFBFBD>if<69><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
6 years ago
break;
}
}
6 years ago
if(!t)
printf("δ<EFBFBD>ҵ<EFBFBD>\n");
6 years ago
fclose(fp);
6 years ago
}
6 years ago
//<2F>޸<EFBFBD> 3.<2E>޸<EFBFBD>
void modify()
6 years ago
{
6 years ago
int a;
char ch[10];
struct user one;
search();
if(t==1)
6 years ago
{
6 years ago
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĵ<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>1.<2E><><EFBFBD><EFBFBD> 2.<2E><><EFBFBD><EFBFBD> 3.<2E>绰1 4.<2E>绰2 5.<2E><><EFBFBD><EFBFBD>\n"); //<2F>޸<EFBFBD><DEB8><EFBFBD>Ϣ<EFBFBD><CFA2>ʾ
scanf("%d",&a);
fp=fopen("user.txt","r+");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>");
switch(a)
{
case 1: scanf("%s",one.name);fprintf(fp,"%-8s",one.name);break;
case 2: fseek(fp,offset+8,SEEK_SET);
scanf("%s",one.place);fprintf(fp,"%-15s",one.place);break;
case 3: fseek(fp,offset+23,SEEK_SET);
scanf("%s",one.tel1);fprintf(fp,"%-15s",one.tel1);break;
case 4: fseek(fp,offset+38,SEEK_SET);
scanf("%s",one.tel2);fprintf(fp,"%-15s",one.tel2);break;
case 5: fseek(fp,offset+53,SEEK_SET);
scanf("%s",one.email);fprintf(fp,"%-20s",one.email);break;
default: break;
}
fclose(fp);
printf("<EFBFBD>޸ijɹ<EFBFBD>\n");
6 years ago
}
6 years ago
}
//ɾ<><C9BE> 4.ɾ<><C9BE>
void dele()
{
char a;
for(;;)
6 years ago
{
6 years ago
search();
if(t==1)
break;
else
printf("<EFBFBD>˳<EFBFBD><EFBFBD>밴N,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
a=getchar();
if(a=='n'||a=='N')
6 years ago
break;
}
6 years ago
if(t==1)
6 years ago
{
6 years ago
fp=fopen("user.txt","r+");
fseek(fp,offset,SEEK_SET);
fprintf(fp,"\n%-8s%-15s%-15s%-15s%-20s\n","","","","","");
fclose(fp);
printf("ɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
6 years ago
}
6 years ago
}
//<2F><><EFBFBD><EFBFBD> 5.<2E><><EFBFBD><EFBFBD>
6 years ago
void look()
{
6 years ago
struct user one;
6 years ago
char c;
if((fp=fopen("user.txt","r"))==NULL) //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>user.txt
{
printf("<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>Ϣʧ<EFBFBD>ܣ<EFBFBD>\n");
exit(0);
}
int m=0;
6 years ago
printf("%-8s%-15s%-15s%-15s%-20s\n","<EFBFBD><EFBFBD><EFBFBD><EFBFBD>","<EFBFBD><EFBFBD><EFBFBD><EFBFBD>","<EFBFBD>绰1","<EFBFBD>绰2","<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
6 years ago
while(!feof(fp))
{
6 years ago
fscanf(fp,"%s%s%s%s%s\n",one.name,one.place,one.tel1,one.tel2,one.email);
printf("%-8s%-15s%-15s%-15s%-20s\n",one.name,one.place,one.tel1,one.tel2,one.email);
6 years ago
m++;
}
if(fclose(fp)) //<2F>ر<EFBFBD><D8B1>ļ<EFBFBD>
{
printf("<EFBFBD>ر<EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
exit(0);
}
6 years ago
}