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.

468 lines
10 KiB

6 years ago
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
#include<process.h>
void add();
void finds();
void clean();
void menus();
void delet();
void modify();
FILE *fp;
int num=0;
struct word
{
char en[100];
char ch[100];
char ex[100];
}s[200];
//<2F><><EFBFBD><EFBFBD>
void clean()
{
int choice;
system("cls");
printf("\n") ;
menus();
scanf("%d",&choice);
printf("\n") ;
switch(choice)
{
case 1:
add();break;
case 2:
finds();break;
case 3:
clean();break;
case 4:
delet();break;
case 5:
modify();break;
case 0:
break;
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
void add()
{
int a,b,c,choice;
char next='1';
char word[100];
FILE *fp;
char en[20];//Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>
char ch[10];
char ex[20];
if((fp=fopen("f4.txt","a+"))==NULL)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ͷ<EFBFBD>ֹ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
{
printf("cann't open file");
exit(0);
}
fseek(fp,0,SEEK_END);//<2F><>λ<EFBFBD><CEBB><EFBFBD>ļ<EFBFBD>ĩβ
while(next=='1')
{
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>Ӣ<EFBFBD><EFBFBD>:");
scanf("%s",en);
strcpy(s[num].en,en);
a=fprintf(fp,"%s\t",s[num].en);
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",ch);
strcpy(s[num].ch,ch);
b=fprintf(fp,"%s\t",s[num].ch);
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
getchar() ;
gets(ex);
strcpy(s[num].ex,ex);
c=fprintf(fp,"%s\n",s[num].ex);
if(a&&b&&c)
{
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>\n");
num++;
printf("%d",num);
}
else
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>\n");
printf("\nWould you like to enter more items(Yes--1/No--<2D><>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)\n");
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD>'#'<27>ż<EFBFBD>") ;
fflush(stdin);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBBBBA><EFBFBD><EFBFBD>
next=getch();
}
if(next=='#')
{
printf("\n") ;
menus();
scanf("%d",&choice);
printf("\n") ;
switch(choice)
{
case 1:
add();break;
case 2:
finds();break;
case 3:
clean();break;
case 4:
delet();break;
case 5:
modify();break;
case 0:
break;
}
}
if(fclose(fp))//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD>ļ<EFBFBD><C4BC>ر<EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
{
printf("cann't close file");
exit(0);
}
}
//<2F><><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>
void finds()
{
rewind(fp);
int i,l,choice,flag=0;
char find='2';
char n,y;
char w[100];
if((fp=fopen("f4.txt","r"))==NULL)//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ͷ<EFBFBD>ֹ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
{
printf("cann't open file");
exit(0);
}
while(find=='2')
{
y='y';
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ҵĵ<EFBFBD><EFBFBD><EFBFBD>:");
while(y=='y')
{
char i=getch();
if(i==27)
return ;/*27ΪESC*/
else
{
if(i==8&&flag>0)/*8ΪBS*/
{
w[--flag]='\0';
system("cls");
printf("ESC:<3A><><EFBFBD><EFBFBD>\n\nBackSpace:ɾ<><C9BE>\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>Ĵʣ<EFBFBD>");
puts(w);
printf("\n");
}
else
{
w[flag]=i;
system("cls");
printf("ESC:<3A><><EFBFBD><EFBFBD>\n\nBackSpace:ɾ<><C9BE>\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>Ĵʣ<EFBFBD>");
puts(w);
printf("\n");
flag++;
}
for(l=0;l<=10;l++)
{
fscanf(fp,"%s\t%s\t%s\n",s[l].en,s[l].ch,s[l].ex);
if(w[0]!='\0')
{
if(strncmp(s[l].en,w,flag)==0)
printf("<EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD>%s\n",s[l].en);
if(strcmp(s[l].en,w)==0)
{
printf("\nӢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ <20><><EFBFBD><EFBFBD> ");
printf("\n %-12s%8s%12s\n",s[l].en,s[l].ch,s[l].ex);
printf("\nq<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD> y---<2D>ǵ<EFBFBD>/n---<2D><><EFBFBD>ǵ<EFBFBD>\n");
y=getch();
}
}
}
}
}
printf("\nWould you like to enter more items(Yes--2/No--<2D><>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)\n");
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD>'#'<27>ż<EFBFBD>") ;
fflush(stdin);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBBBBA><EFBFBD><EFBFBD>
find=getch();
}
if(find=='#')
{
printf("\n") ;
menus();
scanf("%d",&choice);
printf("\n") ;
switch(choice)
{
case 1:
add();break;
case 2:
finds();break;
case 3:
clean();break;
case 4:
delet();break;
case 5:
modify();break;
case 0:
break;
}
}
if(fclose(fp))//<2F>ر<EFBFBD><D8B1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD>ļ<EFBFBD><C4BC>ر<EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
{
printf("cann't close file");
exit(0);
}
}
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
void delet()
{
int choice ;
FILE *fp;
FILE *fp1;
char set[20];
int j,d,h,g,u=0;
int sum=0;
char delets='4';
if((fp=fopen("f4.txt","a+"))==NULL)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ͷ<EFBFBD>ֹ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
{
printf("cann't open f4 file");
exit(0);
}
if((fp1=fopen("linshi.txt","a+"))==NULL)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ͷ<EFBFBD>ֹ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
{
printf("cann't open linshi file");
exit(0);
}
while(delets=='4')
{
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫɾ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD>ʣ<EFBFBD>\n");
scanf("%s",set);
for(j=0;j<=10;j++)//<2F><><EFBFBD>ҵ<EFBFBD><D2B5>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
fscanf(fp,"%s\t%s\t%s\n",s[j].en,s[j].ch,s[j].ex);
if(strcmp(s[j].en,set)!=0)
{
fprintf(fp1,"%s\t",s[j].en);
d=sizeof(s[j].en);
fprintf(fp1,"%s\t",s[j].ch);
h=sizeof(s[j].ch);
fprintf(fp1,"%s\n",s[j].ex);
g=sizeof(s[j].ex);
u=d+g+h;
sum=sum+u;
}
else
{
rewind(fp);
fseek(fp,sum,0);
}
}
if(fclose(fp))//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD>ļ<EFBFBD><C4BC>ر<EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
{
printf("cann't close f4 file");
exit(0);
}
if(fclose(fp1))//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD>ļ<EFBFBD><C4BC>ر<EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
{
printf("cann't close linshi file");
exit(0);
}
remove("f4.txt");
rename("linshi.txt","f4.txt");
printf("\nɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>\n");
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><EFBFBD>,<2C><><EFBFBD>ز˵<D8B2><CBB5><EFBFBD><EFBFBD><EFBFBD>#<23><>,<2C>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n\n");
delets=getch();
}
if(delets=='#')
{
printf("\n") ;
menus();
scanf("%d",&choice);
printf("\n") ;
switch(choice)
{
case 1:
add();break;
case 2:
finds();break;
case 3:
clean();break;
case 4:
delet();break;
case 5:
modify();break;
case 0:
break;
}
}
}
//<2F>޸ĵ<DEB8><C4B5><EFBFBD><EFBFBD><EFBFBD>Ϣ
void modify()
{
int choice;
int o,g=1,j=0;//chooses<65><73><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD>
char choose='5';
char x[100]; //<2F><><EFBFBD>Ҵ<EFBFBD><D2B4>󵥴<EFBFBD>
char y[100]; //<2F><>ȷӢ<C8B7><D3A2><EFBFBD><EFBFBD>ʽ
char z[100]; //<2F><>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
char l[100]; //<2F><>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>
FILE *fp;
FILE *fw;
while(choose=='5')
{
if((fp=fopen("f4.txt","a+"))==NULL)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ͷ<EFBFBD>ֹ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
{
printf("cann't open f4 file");
exit(0);
}
if((fw=fopen("linshi.txt","a+"))==NULL)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ͷ<EFBFBD>ֹ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
{
printf("cann't open linshi file");
exit(0);
}
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵĵ<EFBFBD><EFBFBD><EFBFBD>Ӣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ:");
scanf("%s",x);
fseek(fp,0,SEEK_SET);
for(o=0;o<10;o++)//<2F><><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>Ӣ<EFBFBD><D3A2><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
fscanf(fp,"%s\t%s\t%s\t",s[o].en,s[o].ch,s[o].ex);
if(strcmp(s[o].en,x)!=0)
{
fprintf(fw,"%s\t%s\t%s\n",s[o].en,s[o].ch,s[o].ex);
}
else
{
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>Ӣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ:");
scanf("%s",y);
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ:");
scanf("%s",z);
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
getchar();
gets(l);
j=fprintf(fw,"%s\t%s\t%s\n",y,z,l);
}
}
if(fclose(fp))//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD>ļ<EFBFBD><C4BC>ر<EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
{
printf("cann't close f4 file");
exit(0);
}
if(fclose(fw))//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD>ļ<EFBFBD><C4BC>ر<EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
{
printf("cann't close linshi file");
exit(0);
}
if(j)
printf("\n<EFBFBD>޸ijɹ<EFBFBD><EFBFBD><EFBFBD>\n");
else
{
printf("\n<EFBFBD>޸IJ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
printf("\nû<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD>\n");
}
remove("f4.txt");
rename("linshi.txt","f4.txt");
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>5 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز˵<D8B2><CBB5><EFBFBD>ѡ<EFBFBD><D1A1># <20><>:");
choose=getch();
}
if(choose=='#')
{
printf("\n") ;
menus();
scanf("%d",&choice);
printf("\n") ;
switch(choice)
{
case 1:
add();break;
case 2:
finds();break;
case 3:
clean();break;
case 4:
delet();break;
case 5:
modify();break;
case 0:
break;
}
}
}
//ϵͳ<CFB5>˵<EFBFBD>
void menus()
{
printf("\n");
printf(" *********************************************************\n");
printf(" # #\n");
printf(" # <20><>ѡ<EFBFBD><D1A1>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1> #\n");
printf(" # #\n");
printf(" *********************************************************\n");
printf(" # #\n");
printf(" # 0.<2E>˳<EFBFBD> 1.<2E><><EFBFBD><EFBFBD><EBB5A5> #\n");
printf(" # #\n");
printf(" # 2.<2E><><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD> 3.<2E><><EFBFBD><EFBFBD> #\n");
printf(" # #\n");
printf(" # 4.ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 5.<2E>޸ĵ<DEB8><C4B5><EFBFBD> #\n");
printf(" # #\n");
printf(" *********************************************************\n");
printf("\n");
}
int main()
{
int choice;
printf("\n") ;
menus();
scanf("%d",&choice);
printf("\n") ;
switch(choice)
{
case 1:
add();break;
case 2:
finds();break;
case 3:
clean();break;
case 4:
delet();break;
case 5:
modify();break;
case 0:
break;
}
return 0;
}