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.

293 lines
6.4 KiB

6 years ago
#include<stdio.h>
#include<stdlib.h> /*<2A><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>*/
#include<string.h> /*<2A>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
#include<Windows.h>
#define max 100
#define LEN 15
#define N 50
int k = 1, n = 0, m = 0;
6 years ago
typedef struct Bank {
6 years ago
char no[13];//<2F><><EFBFBD><EFBFBD>
char name[10];//<2F><><EFBFBD><EFBFBD>
char sex[8];//<2F>Ա<EFBFBD>
int balance;//<2F><><EFBFBD><EFBFBD>
char passwd[20];
6 years ago
} bank, ban[max];
void fileWrite(int n, ban s);
6 years ago
void modify() {
int j = 0;
FILE * fp;
if ((fp = fopen("a.txt", "r")) == NULL) return;
6 years ago
ban s;
6 years ago
while (fscanf(fp, "%s %s %s %s %d ", &s[j].no, &s[j].name, &s[j].sex[j],&s[j].passwd, &s[j].balance) == 5) {
j++;
}
n = j;
int i, item, num;
int age;
char sex1[8], s1[LEN + 1], s2[LEN + 1],passwd1[20],age1[10];
float score1;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵ<EFBFBD><EFBFBD>û<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>:\n");
scanf("%s", s1);
for (i = 0; i<n; i++) {
if (strcmp(s[i].no, s1) == 0) { /*<2A>Ƚ<EFBFBD><C8BD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>*/
num = i;
printf("------------------\n");
printf("1.<2E>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>\n");
printf("2.<2E>޸<EFBFBD><DEB8>Ա<EFBFBD>\n");
printf("3.<2E>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>\n");
printf("4.<2E>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>˵<EFBFBD>\n");
printf("------------------\n");
while (1) {
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>Ӳ˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d", &item);
switch (item) {
case 1:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
scanf("%s", s2);
strcpy(s[num].name, s2);
fileWrite(n, s);
break;
case 2:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD>Ա<EFBFBD>:\n");
scanf("%s", &sex1);
strcpy(s[num].sex, sex1);
fileWrite(n, s);
break;
case 3:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
scanf("%s", &passwd1);
strcpy(s[num].passwd, passwd1);
fileWrite(n, s);
break;
case 4:
return;
default:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1-4֮<34><D6AE>ѡ<EFBFBD><D1A1>\n");
}
}
}
else {
printf("û<EFBFBD>иÿ<EFBFBD><EFBFBD><EFBFBD>!!!\n");
}
}
system("pause");
}
void insert() {
int i, a, b;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>:\n");
scanf("%d", &n);
FILE * fp;
if ((fp = fopen("a.txt", "at")) == NULL) return;
6 years ago
ban s;
6 years ago
for (i = 0; i<n; i++) {
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64><EFBFBD>û<EFBFBD><C3BB>Ŀ<EFBFBD><C4BF>ţ<EFBFBD>", i + 1);
scanf("\n%s", &s[i].no);
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", i + 1);
scanf("%s", &s[i].name);
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d <20><><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>", i + 1);
scanf("%s", &s[i].sex);
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d <20><><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", i + 1);
scanf("%s", &s[i].passwd);
//д<><D0B4><EFBFBD>ļ<EFBFBD>
6 years ago
fseek(fp, 0L, SEEK_END);
6 years ago
fprintf(fp, "%s %s %s %s %d \n", s[i].no, s[i].name, s[i].sex,s[i].passwd, s[i].balance = 0);
6 years ago
fclose(fp);
6 years ago
}
printf("<EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD>!!!\n");
system("pause");
}
void del() {
int j = 0;
FILE * fp, *fp1;
if ((fp = fopen("a.txt", "r")) == NULL) return;
6 years ago
ban s;
6 years ago
while (fscanf(fp, "%s %s %s %s %d ", &s[j].no, &s[j].name, &s[j].sex[j],&s[j].passwd, &s[j].balance) == 5) {
j++;
}
n = j;
int i, flag = 0;
char s1[LEN + 1];
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫɾ<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>:\n");
scanf("%s", s1);
for (i = 0; i<n; i++) {
if (strcmp(s[i].no, s1) == 0) {
flag = 1;
for (j = i; j<n - 1; j++) {
strcpy(s[j].no, s[j + 1].no);
strcpy(s[j].name, s[j + 1].name);
s[j].balance = s[j + 1].balance;
strcpy(s[j].sex, s[j + 1].sex);
strcpy(s[j].passwd, s[j + 1].passwd);
}
}
}
if (flag == 0)
printf("<EFBFBD>ÿ<EFBFBD><EFBFBD>Ų<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>\n");
if (flag == 1) {
n--;
fileWrite(n, s);
fclose(fp);
printf("ɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>,<2C><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>˵<EFBFBD>\n");
}
system("pause");
}
void seek() {
int j = 0,flag=0;
FILE * fp;
if ((fp = fopen("a.txt", "r")) == NULL) return;
6 years ago
ban s;
6 years ago
while (fscanf(fp, "%s %s %s %s %d", &s[j].no, &s[j].name, &s[j].sex[j], &s[j].passwd, &s[j].balance) == 5) {
j++;
}
n = j;
int i = 0, item;
char s1[13], s2[20];
lable1:
6 years ago
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>)<29><>\n");
6 years ago
scanf("%s", &s1);
6 years ago
if (strcmp(s1, "0") == 0)
6 years ago
{
return;
}
6 years ago
for (i = 0; i < n; i++) {
if (strcmp(s[i].no, s1) == 0) {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%s", &s2);
if (strcmp(s[i].passwd, s2) == 0) {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
printf("<EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>%s\n", s[i].no);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%s\n", s[i].name);
printf("<EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD>%s\n", s[i].sex);
printf("<EFBFBD><EFBFBD><EFBFBD>%d\n", s[i].balance);
flag = 2;
break;
}
else {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
goto lable1;
}
}
}
if (flag != 2) {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
goto lable1;
}
fclose(fp);
system("pause");
}
6 years ago
void save()
{
int j = 0,flag=0;
FILE * fp;
6 years ago
if ((fp = fopen("a.txt", "r+")) == NULL) return;
ban s;
6 years ago
while (fscanf(fp, "%s %s %s %s %d", &s[j].no, &s[j].name, &s[j].sex[j], &s[j].passwd, &s[j].balance) == 5) {
j++;
}
n = j;
6 years ago
struct Bank *str = s;
int i = 0, item,save,aftersave;
6 years ago
char s1[13], s2[20];
lable1:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>)<29><>\n");
scanf("%s", &s1);
6 years ago
if (strcmp(s1, "0") == 0)
6 years ago
{
return;
}
for (i = 0; i < n; i++) {
if (strcmp(s[i].no, s1) == 0) {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%s", &s2);
if (strcmp(s[i].passwd, s2) == 0) {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD>");
scanf("%d",&save);
6 years ago
s[i].balance = save + s[i].balance;
fileWrite(n, s);
fclose(fp);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!\n");
printf("<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ%dԪ\n",s[i].balance);
6 years ago
flag = 2;
break;
}
else {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
goto lable1;
}
}
}
if (flag != 2) {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
goto lable1;
}
6 years ago
6 years ago
system("pause");
}
6 years ago
void fileWrite(int n, ban s) {
6 years ago
FILE *fp1;
int i;
if ((fp1 = fopen("a.txt", "w")) == NULL) return;
for (i = 0; i<n; i++) {
fprintf(fp1, "%s %s %s %s %d ", s[i].no, s[i].name, s[i].sex,s[i].passwd, s[i].balance);
}
fclose(fp1);
}
/* <20><><EFBFBD><EFBFBD>*/
void menu() {
int num;
printf("------------------------------------------------------\n");
printf("------------------------------------------------------\n");
printf("-------------------<2D><><EFBFBD>й<EFBFBD><D0B9><EFBFBD>ϵͳ-----------------------\n");
printf("------------------------------------------------------\n");
printf("------------------------------------------------------\n");
Sleep(3000);
system("CLS");
printf("------------------------------------------------------\n");
printf("----------------------<2D><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>----------------------\n");
printf("-------------------1.<2E><>ѯ 2.<2E><><EFBFBD><EFBFBD>--------------------\n");
printf("-------------------3.ȡ<><C8A1> 4.<2E><><EFBFBD><EFBFBD>--------------------\n");
printf("-------------------5.<2E><><EFBFBD><EFBFBD> 6.<2E>˻<EFBFBD><CBBB><EFBFBD>Ϣ<EFBFBD>޸<EFBFBD>------------\n");
printf("-----------------------0.<2E>˳<EFBFBD>-------------------------\n");
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d", &num);
switch (num) {
case 0:
exit(0);
break;
case 1:
seek();
break;
case 2:
6 years ago
save();
6 years ago
break;
case 3:
break;
case 4:
insert();
break;
case 5:
del();
break;
case 6:
modify();
break;
default:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-6֮<36><D6AE>ѡ<EFBFBD><D1A1>\n");
}
}
int main() {
while (k) {
system("cls");
menu();
}
system("pause");
return 0;
}