From e1d0708ceff03fe9fbf0e8223ae3cf3d0f8256ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=90=E7=83=A8=20=E6=A2=85?= <1042906887@qq.com> Date: Sun, 30 Dec 2018 18:15:47 +0800 Subject: [PATCH] first commit --- translation/query log.txt | Bin 0 -> 3528 bytes translation/trans.h | 54 +++ translation/username_pwAD.txt | 4 + translation/username_pwCOM.txt | 0 translation/word_coll.txt | Bin 0 -> 504 bytes translation/wordd.txt | Bin 0 -> 2520 bytes translation/wordd_coll.txt | 0 translation/源.cpp | 786 +++++++++++++++++++++++++++++++++ 8 files changed, 844 insertions(+) create mode 100644 translation/query log.txt create mode 100644 translation/trans.h create mode 100644 translation/username_pwAD.txt create mode 100644 translation/username_pwCOM.txt create mode 100644 translation/word_coll.txt create mode 100644 translation/wordd.txt create mode 100644 translation/wordd_coll.txt create mode 100644 translation/源.cpp diff --git a/translation/query log.txt b/translation/query log.txt new file mode 100644 index 0000000000000000000000000000000000000000..104f604bbb9c8fe8eaf6acc85ca4a5f725e0f702 GIT binary patch literal 3528 zcmYc+C}22CV{m!d<-;_$gvNdV8DEl-T9m4gS*%c;pPO2ek(rmSP+pV|A~Q=e6o9fo zsl +#include +#include +#include +#include +#include +#include + + + + +//ѯ¼ + + + +struct w_word { + char word_[100]; + char trans_[200]; + char setence[200]; + int at; +}*tr,*wd; + + +//ԱϢ +struct user_pw { + char name[101]; + char pw[101]; + int at=0; +} *regin, *regip; + + +//ûϢ +struct user_pwC { + char name[101]; + char pw[101]; + int at=0; +}*regi_n, *regi_p; + +struct userna_pw { + char name1[101]; + char passd1[101]; + char passd2[101]; +}uni1; + +struct userna_pw regi; + + + + diff --git a/translation/username_pwAD.txt b/translation/username_pwAD.txt new file mode 100644 index 0000000..688f0c4 --- /dev/null +++ b/translation/username_pwAD.txt @@ -0,0 +1,4 @@ +123 +123 +132 +123 diff --git a/translation/username_pwCOM.txt b/translation/username_pwCOM.txt new file mode 100644 index 0000000..e69de29 diff --git a/translation/word_coll.txt b/translation/word_coll.txt new file mode 100644 index 0000000000000000000000000000000000000000..3d6aa9cb319b455b305cd55a6e93a7ca668d367a GIT binary patch literal 504 zcmYc+C}22CV{m!d<-;_$gvNdV8DEl-T9m4gS*%c;pPO2ek(rmSP+pV|A~Q=e6o9fo QslNDN$lcshAwcWZ?BZGSKl>;w z<*?m6gd=zq@v>ml2tl#j46WI6fBcR?b(PCU*2?+5TgxVhE3X2+-fL(-&^EeNc}KDu zNmR??S>(FTPdCvRarvDOt9I?b?-PM9!SnuyGFo(+{$UF+sIiY)+Qw?SJW6MXOJ`Qm hro84IAd#A|a@F<21f|W}-wd6OsDXh}(P;h5>J16yD{%k- literal 0 HcmV?d00001 diff --git a/translation/wordd_coll.txt b/translation/wordd_coll.txt new file mode 100644 index 0000000..e69de29 diff --git a/translation/源.cpp b/translation/源.cpp new file mode 100644 index 0000000..df589d2 --- /dev/null +++ b/translation/源.cpp @@ -0,0 +1,786 @@ +#pragma once +#include"trans.h" + + +#define LEN 50 + + +struct user_pwC *na0, *pw0; +//struct userna_pw *na1, *pw1; + +void loginAD(); +void ADMIN(); +void COMMON(); +void PRINTF1_1(); +void PRINTF2_1(); +void PRINTF3_1(); +void IMPORT(); +void VIEW(); +void LOANDMA(); +void WORD_CO(struct w_word *inpu); +void FWORD_CO(); +void QUE(struct w_word *input); +void FQUE(); + +void REGISTCOM() { //ûע + system("cls"); + struct userna_pw *regi1=(struct userna_pw*)malloc(sizeof(struct userna_pw)); + FILE *fp; + fp = fopen("username_pwCOM.txt", "a+"); //******************* //ûýṹļ + //memset(regi1->name1, 0, 101 * sizeof(char)); + //memset(regi1->passd1, 0, 101 * sizeof(char)); + //memset(regi1->passd2, 0, 101 * sizeof(char)); + printf("\t*************************\n"); + printf("\t* û *\n"); + gets_s(regi1->name1); + //na0 = &uni0; + //pw0 = na0; + while (1) { + printf("\t* *\n"); + gets_s(regi1->passd1); //ͬṹļ + printf("\t* һĵ: *\n"); + gets_s(regi1->passd2); + + if (strcmp(regi1->passd1, regi1->passd2)) { + printf("\t*Ķ벻*\n"); + printf("\t* *\n"); + } + else { + //strcpy(regi_n->name, regi1.name1); + //strcpy(regi_p->pw, regi1.passd1); + + fwrite(regi1,sizeof(struct userna_pw),1 ,fp); + //fputs("\n", fp); + //fputs(regi1.passd1, fp); + //fputs("\n", fp); + printf("*עɹ*\n"); + system("pause"); + fclose(fp); + break; + } + } //һбȶ + return ; +} +void loginCOM() //û +{ + system("cls"); + struct userna_pw *log1 = (struct userna_pw*)malloc(sizeof(struct userna_pw)); + struct userna_pw *t=(struct userna_pw*)malloc(sizeof(struct userna_pw)); + //memset(log1->name1, 0, 101 * sizeof(char)); + //memset(log1->passd1, 0, 101 * sizeof(char)); + //memset(log1->passd2, 0, 101 * sizeof(char)); + printf("\t**********************\n"); + printf("\t* û *\n"); + gets_s(log1->name1); + printf("\t* *\n"); + gets_s(log1->passd2); //ļ¼ ļṹȶ + //strcat(log1->passd2, "\n"); + //strcat(log1->name1, "\n"); + FILE *fp1; + fp1 = fopen("username_pwCOM.txt", "r"); + if (fp1 == NULL) { + printf("޴ļ\n"); + return; + } + int ok = 0; + while (!feof(fp1)) { + //fread(t.name1, sizeof(struct userna_pw), 1, fp1); + //fread(t.passd1, sizeof(struct userna_pw), 1, fp1); + while (fread(t, sizeof(struct userna_pw), 1, fp1) != NULL) { + //fgets(t.passd1, sizeof(t.passd1), fp1); + if (!strcmp(t->name1, log1->name1) && !strcmp(t->passd1, log1->passd2)) { + ok = 1; + } + } + } + if (ok == 1) { + printf("ɹ"); + printf("\t* سһ *\n"); + system("pause"); + COMMON(); + } + else { + printf("ʧ"); + system("pause"); + fclose(fp1); +} + return; +} + +void REGISTAD() { //Աע + system("cls"); + + memset(regi.name1, 0, 101 * sizeof(char)); + memset(regi.passd1, 0, 101 * sizeof(char)); + memset(regi.passd2, 0, 101 * sizeof(char)); + FILE *fp; + fp = fopen("username_pwAD.txt", "a+"); //******************* + printf("\t*************************\n"); + printf("\t* û *\n"); + gets_s(regi.name1); + //na1 = &uni1; + //pw1 = na1; + while (1) { + printf("\t* *\n"); + gets_s(regi.passd1); //ͬṹļ + printf("\t* һĵ: *\n"); + gets_s(regi.passd2); + + + if (strcmp(regi.passd1, regi.passd2)) { + printf("\t*Ķ벻*\n"); + printf("\t* *\n"); + } + else { + + //strcpy(regin->name, regi.name1); + //strcpy(regin->pw, regi.passd1); + + fputs(regi.name1, fp); + fputs("\n", fp); + fputs(regi.passd1, fp); + fputs("\n", fp); + printf("*עɹ*\n"); + system("pause"); + fclose(fp); + loginAD(); + break; + } + } //һбȶ + return; +} +void loginAD() //Ա +{ + system("cls"); + struct userna_pw log,t1; + memset(log.name1, 0, 101 * sizeof(char)); + memset(log.passd1, 0, 101 * sizeof(char)); + memset(log.passd2, 0, 101 * sizeof(char)); + printf("\t**********************\n"); + printf("\t* û *\n"); + printf("\t**********************\n"); + gets_s(log.name1); //ļû + printf("\t* *\n"); + gets_s(log.passd2); //ļ¼ ļṹȶ + strcat(log.passd2, "\n"); + strcat(log.name1, "\n"); + FILE *fp1; + fp1 = fopen("username_pwAD.txt", "r"); + if (fp1 == NULL) { + printf("޴ļ\n"); + return ; + } + int ok=0; + while (!feof(fp1)) { + fgets(t1.name1, sizeof(t1.name1), fp1); + fgets(t1.passd1, sizeof(t1.passd1), fp1); + if (!strcmp(t1.name1, log.name1) && !strcmp(t1.passd1, log.passd2)) { + ok = 1; + } + + } + if (ok == 1) { + printf("ɹ\n\n\n"); + printf("\t* سһ *\n"); + system("pause"); + ADMIN(); + + } + else { + printf("ʧ"); + printf("\t* سһ *\n"); + system("pause"); + fclose(fp1); + } + return; + +} + + +char PRINTF1() { + char key = 'a'; + while(1){ + do + { + system("cls"); + printf("\t*****************************\n"); + printf("\t* 1.οͽ *\n"); + printf("\t* *\n"); + printf("\t* 2.ͨûע *\n"); + printf("\t* *\n"); + printf("\t* 3.Աע *\n"); + printf("\t* 4.˳ *\n"); + printf("\t*****************************\n"); + printf("ҪеĴ֣\n"); + key = getch(); + } while (key != '1' && key != '2' &&key != '3'&&key !='4'); + switch (key) + { + case '1': + PRINTF1_1(); break; + case '2': + PRINTF2_1(); break; + case '3': + PRINTF3_1(); break; + case '4': + exit(0); + default: + printf(""); + break; + } + } +} +//ѯ +void PRINTF1_1() +{ + + int x = 0; + FILE *fp; + fp = fopen("wordd.txt", "r"); + char tempor[100]; + struct w_word *check = (struct w_word *)malloc(sizeof(struct w_word)); + struct w_word *chec = (struct w_word *)malloc(sizeof(struct w_word)); + memset(tempor, 0, 100 * sizeof(char)); + system("cls"); + printf("\t*****************************************\n"); + printf("\t* 1.Ҫѯĵ *\n"); + printf("\t*****************************************\n"); + int i = 0; + scanf("%s", tempor); + while (fread(chec, sizeof(struct w_word), 1, fp) != NULL) { + if (strstr(chec->word_, tempor) !=NULL) { + printf("\n"); + printf("%s", chec->word_); + //fread(strstr(((struct w_word *)check)->trans_, tempor), sizeof(struct w_word), 20, fp); + //puts(check->trans_); + //printf("\n"); + //printf(".\t"); + //fwrite(((struct w_word *)check)->setence, sizeof(struct w_word),20, fp); + //puts(check->setence); + printf("\n"); + //x = 1; + //break; + //system("pause"); + } + } + rewind(fp); + //fclose(fp); + //printf("\t* سһ \n"); + //system("pause"); + //FILE *fpp; + //fpp = fopen("wordd.txt", "r"); + while (fread(check, sizeof(struct w_word),1, fp) != NULL) { + if (strstr(check->word_, tempor) == (char *)(check->word_)) { + printf("\n"); + printf("%s: ",check->word_); + //fread(strstr(((struct w_word *)check)->trans_, tempor), sizeof(struct w_word), 20, fp); + puts(check->trans_); + //printf("\n"); + printf(".\t"); + //fwrite(((struct w_word *)check)->setence, sizeof(struct w_word),20, fp); + puts(check->setence); + printf("\n"); + x = 1; + break; + //system("pause"); + } + } + //system("pause"); + //printf("\t* سһ \n"); + system("pause"); + + if(x==0) { + printf("\t* Ҳ˵ʷ *\n"); + system("pause"); + + return ; + } + else { + + QUE(check); + char key; + do { + printf("\t*****************************************\n"); + printf("\t* ǷҪ˵ʼ¼ʼ¼ *\n"); + printf("\t* 1. *\n"); + printf("\t* 2. *\n"); + printf("\t*****************************************\n"); + key = getch(); + } while (key == '1'&&key == '2'); + if (key == '1') { + WORD_CO(check); //浥ղر + printf("\t* Ѵ *\n"); + system("pause"); + } + } fclose(fp); + return ; +} + + +//¼ע +void PRINTF2_1() { + + char key2_1=0; + do + { + system("cls"); + printf("\t***********************************\n"); + printf("\t* ͨû *\n"); + printf("\t* 1. *\n"); + printf("\t* 2.ע *\n"); + printf("\t* 3.˳*\n"); + printf("\t***********************************\n"); + key2_1 = getch(); + } while (key2_1 != '1' && key2_1 != '2'&& key2_1 != '3'); + if (key2_1 == '1') { + loginCOM(); + return; + } + else if (key2_1 == '2') { + REGISTCOM(); + printf("* 밴س *\n"); + system("pause"); + loginCOM(); + return; + } + else + return; + + +} +void PRINTF3_1() { + + char key3_1=0; + do + { + system("cls"); + printf("\t*****************************\n"); + printf("\t* Ա *\n"); + printf("\t* 1. *\n"); + printf("\t* 2.ע *\n"); + printf("\t* 3.˳*\n"); + printf("\t*****************************\n"); + key3_1 = getch(); + } while (key3_1 != '1'&&key3_1 != '2'&&key3_1 != '3'); + if (key3_1 == '1') { + loginAD(); + return; + } + else if (key3_1 == '2') { + REGISTAD(); + printf("\t * *\n"); + system("pause"); + loginAD(); + return; + } + else + return; +} + +//Ա +void ADMIN() { + char keyA=0; + while (1) { + + do + { + system("cls"); + printf("\t*****************************************\n"); + printf("\t* 1.ѯ *\n"); + printf("\t* 2.뵥 *\n"); + printf("\t* 3.鿴Ϣ *\n"); + printf("\t* 4.鿴͹û *\n"); + printf("\t* 5.˳ *\n"); + printf("\t*****************************************\n"); + keyA = getch(); + } while (keyA != '1'&&keyA != '2'&&keyA != '3'&&keyA != '4'&&keyA != '5'); + switch (keyA) + { + case '1': + PRINTF1_1(); + break; + case '2': + IMPORT(); + break; + case '3': + VIEW(); + break; + case '4': + LOANDMA(); + break; + case '5': + return; + default: + printf("\t\t"); + break; + } + } +} +//ͨû +void COMMON() { + char keyC=0; + while(1){ + do + { + system("cls"); + printf("\t*****************************\n"); + printf("\t* 1.ѯ *\n"); + printf("\t* 2.ղر *\n"); + printf("\t* 3.ѯ¼ *\n"); + printf("\t* 4.˳ *\n"); + printf("\t*****************************\n"); + keyC = getch(); + } while (keyC != '1'&&keyC != '2'&&keyC != '3'&&keyC != '4'); + switch (keyC) + { + case '1': + PRINTF1_1(); + + break; + case '2': + FILE *fp0; + fp0 = fopen("wordd_coll.txt", "a"); + char bbb[5]; + if (fgets(bbb,1,fp0) == NULL) { + printf("\t* ûд뵥 ղرΪ *\n"); + system("pause"); + } + else { + fclose(fp0); + FWORD_CO(); + } + break; + case '3': + FILE *fp_; + fp_ = fopen("query log.txt", "a"); + char ccc[5]; + if ((fgets(ccc, 1, fp_) == NULL)){ + + printf("\t* ûвѯ ¼Ϊ *\n"); + system("pause"); + } + else { + fclose(fp_); + FQUE(); + } + + break; + case '4': + return; + default: + printf("\t\t"); + break; + } + } +} + +//뵥 +void IMPORT() { //뵥 + system("cls"); + + FILE *fp2; + fp2 = fopen("wordd.txt", "a+"); + int n,x=0; + printf("\t*****************************************\n"); + printf("\t* Ҫٸ *\n"); + printf("\t*****************************************\n"); + scanf("%d",&n); + tr = (struct w_word*)malloc( n * sizeof(struct w_word)); + wd = (struct w_word*)malloc(n * sizeof(struct w_word)); + for (int i = 0; i < n; i++) { + printf("******** %d *********\n",i+1); + printf("\n"); + printf("\t* 뵥 *\n"); + scanf("%s",&(tr + i)->word_); + //(tr + i)->word_[strlen((tr + i)->word_) ]='\0'; + //fputs((wd+i)->word_, fp2); + //fputs(" ", fp2); + printf("\t* ǰ浥ʵķ *\n"); + scanf("%s", &(tr + i)->trans_); + getchar(); + //fputs((tr + i)->trans_, fp2); + //fputs("\n", fp2); + printf("\n"); + printf("\t* ǰ浥ʵ *\n"); + gets_s((tr+ i)->setence); + //fputs((wd + i)->setence, fp2); + //fputs("\n", fp2); + rewind(fp2); + while (feof(fp2) != EOF) { + while (fread(wd, sizeof(struct w_word), 1, fp2) != NULL) { + if ((tr + i)->word_ == wd->word_) { + printf("\t* ˵Ѿ 벻Ҫظ \t"); + system("pause"); + x = 1; + } + } + break; + } + if (x == 0) + fseek(fp2, 0L, SEEK_END); + fwrite((tr+i),sizeof(struct w_word),1,fp2); + printf("\n"); + } + //rewind(fp2); + + fclose(fp2); + return; +} +//鿴еʱ +void VIEW() { //鿴еϢ + struct w_word *exi=(struct w_word *)malloc(sizeof(struct w_word)); + FILE *fp4; + fp4 = fopen("wordd.txt", "r"); + if (fp4 == NULL) { + printf("\t** ļδ¼뵥 **\n "); + return; + } + else { + while (feof(fp4) != EOF) { + while (fread(exi, sizeof(struct w_word), 1, fp4) !=NULL){ + printf("%s ", exi->word_); + puts(exi->trans_); + puts("\n"); + } + break; + } + } + fclose(fp4); + system("pause"); + return; +} +//鿴͹û +void LOANDMA() { + int x = 0; + struct userna_pw *usp=(struct userna_pw*)malloc(sizeof(struct userna_pw)); + char number[100]; + //char n[20]; + FILE *fp5; + fp5 = fopen("username_pwCOM.txt", "r"); + if (fp5== NULL) { + printf("\t** û **\n "); + while (getchar() != '\n') + continue; + return; + } + else { + while (feof(fp5) != EOF) { + while (fread(usp,sizeof(struct userna_pw),1,fp5) != NULL) { + printf("****û"); + puts(usp->name1); + printf("****룺"); + puts(usp->passd1); + } + break; + } + + } + //fflush(fp5); + fclose(fp5); + system("pause"); + printf("\t* Ƿѡɾû *\n"); + printf("\t* 1. 2. *\n"); + char keyy = getch(); + if (keyy == '1') { + FILE *fpp; + fpp = fopen("username_pwCOM.txt","r"); + rewind(fpp); + //struct userna_pw asd; + struct userna_pw us[105]; + int i=0,m1=(-1),qu=0; + while (1) { + printf("\t* ûû *\n"); + scanf("%s", number); + if (number[0] == '\0') { + printf(" 󣡣 "); + continue; + } + else + break; + } + while (!feof(fpp)) { + if (fread(&us[i], sizeof(struct userna_pw), 1, fpp) != NULL) { + i++; + } + } + fclose(fpp); + if (i == 0) { + printf("* û *"); + system("pause"); + return; + } + for (int m = 0; m < i; m++) { + if (strcmp(us[m].name1, number) == 0) { + m1 = m; + break; + } + } + if(m1==-1){ + printf("* û *"); + qu = 1; + + } + else { + for (int s = m1; s < i; s++) { + us[s] = us[s + 1]; + } + i--; + if ((fpp = fopen("username_pwCOM.txt", "w")) == NULL) { + return; + } + for (int k = 0; k < i; k++) { + if (fwrite(&us[k], sizeof(struct userna_pw), 1, fpp) != 1) { + printf("* ɾʧ *"); + system("pause"); + x = 1; + } + } + //printf("* ɾɹ *"); + } + if (x == 0) { + printf("\t* ɾɹ *\n"); + printf("\t* سһ *\n"); + system("pause"); + } + + return; + } + else { + return; + } + +} +//浥ʼ¼ +void WORD_CO(struct w_word *inpu) { + FILE *fp6; + fp6 = fopen("word_coll.txt", "a"); + fwrite(inpu,sizeof(struct w_word),1, fp6); + fclose(fp6); + return; + +} +//ʾʼ¼ +void FWORD_CO() { + system("cls"); + printf("\t*****************************************\n"); + printf("\t* ʼ¼ *\n"); + printf("\t*****************************************\n"); + struct w_word *fword=(struct w_word *)malloc(sizeof(struct w_word)); + //struct word_coll { + // char word1[100]; + // char trans1[200]; + // struct word_coll *next; + // int a; + //}; + //struct word_coll *head = NULL; + //struct word_coll *prev=NULL, *current; + char input[50]; + FILE *fp7; + fp7 = fopen("word_coll.txt", "r"); + if (fp7 == NULL) { + printf("\t* ¼޵ *\n"); + system("pause"); + return; + } + while (feof(fp7) != EOF) { + while (fread(fword, sizeof(struct w_word), 1, fp7) != NULL && input[0] != '\0') { + //current = (struct word_coll*)malloc(sizeof(struct word_coll)); + //if (head == NULL) + // head = current; + //else + //prev->next = current; + //current->next = NULL; + puts(fword->word_); + puts(fword->trans_); + //prev = current; + //memset(input, 0, sizeof(char) * 50); + } + } + printf("\t**************س*****************\n"); + system("pause"); + return; +} +//ѯ¼ +void QUE(struct w_word *input) { + FILE *fps; + fps = fopen("query log.txt", "a"); + fwrite(input,sizeof(struct w_word),1,fps); + fclose(fps); + return; +} +//ʾѯ¼ +void FQUE() { + system("cls"); + printf("\t*****************************************\n"); + printf("\t* ѯ¼ *\n"); + printf("\t*****************************************\n"); + struct w_word *fque = (struct w_word *)malloc(sizeof(struct w_word)); + //struct query_l { + // char word2[100]; + // char trans2[200]; + // struct query_l *next; + // int a; + //}; + //struct query_l *head = NULL; + //struct query_l *prev=NULL , *current; + //char inputt[50]; + FILE *fp7; + fp7 = fopen("query log.txt", "r"); + while (feof(fp7) != EOF) { + while (fread(fque, sizeof(struct w_word), 1,fp7) != NULL) { + //current = (struct query_l*)malloc(sizeof(struct query_l)); + //if (head == NULL) + // head = current; + //else + // prev->next = current; + //current->next = NULL; + puts(fque->word_); + puts(fque->trans_); + //prev = current; + //memset(inputt, 0, sizeof(char) * 50); + } + } + printf("\t**************س*****************\n"); + while (getchar() != '\n') + continue; + return; +} +//ʾʱ +void SORT() { + char *ptsw[10000], *ptst[10000]; + int a=5; + //a = sizeof(wd) / sizeof(struct w_word); + + for (int i = 0; i < a; ++i) { + // ptsw[i] = (wd -i)->word_; + ptst[i] = (tr - i)->trans_; + } + char*temp,*temp1; + int top, seek; + for (top = 0; top < a - 1; top++) { + for (seek = top + 1; seek < a; seek++) { + if (strcmp(ptsw[top], ptsw[seek]) > 0) { + temp = ptsw[top]; + ptsw[top] = ptsw[seek]; + ptsw[seek] = temp; + + temp1 = ptst[top]; + ptst[top] = ptst[seek]; + ptst[seek] = temp1; + } + } + } + for (int k = 0; k < a; k++) { + puts(ptsw[k]); + printf("\t"); + puts(ptsw[k]); + printf("\n"); + } + return; +} + + +int main() { + PRINTF1(); // + return 0; +}