?? account1
字號:
#include "function.h"
const int length=41;
void main()
{
while(1)
{
FILE * c=fopen("interest.txt","r+");
int adaccount;
int adpassword;
double interestForFix;
double interestForUnfix;
int currentmonth;
fscanf(c,"%d",&adaccount);
fscanf(c,"%d",&adpassword);
fscanf(c,"%lf",&interestForFix);
fscanf(c,"%lf",&interestForUnfix);
fscanf(c,"%d",¤tmonth);
fclose(c);
Item administrater;
printf("please enter your account and password:\n");
int account;
scanf("%d", &account);
int password;
scanf("%d", &password);
if(account!=adaccount||password!=adpassword)
{
printf("not the administater...exit...\n");
exit(1);//退出也可以
}
else
{
while(1)
{
printf("loading the data...\n");
//*******index***********//
FILE* b=fopen("index.txt","r");
Item temp;
Index temp1;
int i;
if(!b)
{
FILE* a=fopen("database.txt","r+");
FILE* b=fopen("index.txt","w+");
fseek(a,0,SEEK_END);
int pos=ftell(a);
for(i=0;length*i<pos;i++)
{
temp.Fin(i,a);
fprintf(b,"%d %d\n", temp.account, i);
}
fflush(b);
fclose(a);
fclose(b);
//***********avl*****************//
}
avlTree bankTree;
{
FILE* d=fopen("index.txt","r+");
for(;!feof(d);)
{
int acc,pos;
fscanf(d, "%d %d", &acc, &pos);
temp1.pos=pos;
temp1.account=acc;
bankTree.add(temp1);
}
fclose(d);
}
//打開文件留在整體使用
FILE * infile=fopen("database.txt","r+");
while(1)
{
printf("*************welcome**********\n");
printf("please enter your account:\n");
int userAccount;
scanf("%d",&userAccount);
printf("please enter your password:\n");
int userPW;
scanf("%d",&userPW);
if(userAccount!=0)
{
Index tmp;
tmp.account=userAccount;
avlNode * find=bankTree.findValue(tmp);//avl成員函數,修改
if(!find)
{
printf("could not find this account\n");
continue;
}
else
{
Item user;
findUser(infile,find,user);
bool pw=checkpass(user,userPW);
if(!pw)
{
printf("wrong password\n");
continue;
}
else
{
printf("please choose the service:\n");
printf("1.getmoney\n");
printf("2.savemoney\n");
printf("3.check your account\n");
printf("4.change the password\n");
printf("5.exit\n");
bool oper;
char op[100];
scanf("%s",op);
while(1)
{
if(op[0]=='1')
{
oper=getMoney(user, interestForFix, interestForUnfix, currentmonth);//取錢
if(oper)
{
printf("please receive your money\n");
}
else
printf("fail to get money...\n");
}
else if(op[0]=='2')
{
oper=saveMoney(user, interestForFix, interestForUnfix, currentmonth);//存錢
if(oper)
{
printf("your money has been added into your account\n");
}
else
printf("fail to save money...\n");
}
else if(op[0]=='3')
{
Check(user,currentmonth);//查看信息
}
else if(op[0]=='4')
{
oper=changePW(user);//修改密碼
if(oper)
{
printf("your password has been changed , please remember...\n");
}
else
printf("fail to change the password\n");
}
else if(op[0]=='5')
{
store(infile,find,user);//存儲
fflush(infile);
break;
}
else
{
printf("please choose the right service:\n");
}
printf("please choose the service:\n");
printf("1.getmoney\n");
printf("2.savemoney\n");
printf("3.check your account\n");
printf("4.change the password\n");
printf("5.exit\n");
scanf("%s",op);
}//end while
}//end else
}//end else
continue;
}//end if
else//administrater
{
printf("please choose your operation:\n");
printf("1.changeTime\n");
printf("2.add user\n");
printf("3.delete user\n");
printf("4.check user\n");
printf("5.change the interest\n");
printf("6.change the pass word\n");
printf("7. end the operations\n");
printf("8. leave\n");
char op[100];
scanf("%s",op);
bool oper;
while(1){
if(op[0]=='1')
{
changeTime(currentmonth);
}
else if(op[0]=='2')
{
oper=addUser(infile, bankTree, currentmonth);
if(oper)
{
printf("the user has been added into the database\n");
}
else
printf("fail to add the user\n");
}
else if (op[0]=='3')
{
oper=deleteUser(infile, bankTree);
if(oper)
{
printf("the user has been deleted into the database\n");
}
else
printf("fail to deleted the user\n");
}
else if (op[0]=='4')
{
int useracc;
while(1){
printf("1.display all users\n");
printf("2.display selected user\n");
scanf("%s",op);
char name[100];
if(op[0]=='1'){
while(1){
printf("1.print to screen\n");
printf("2.print to file\n");
scanf("%s", op);
if(op[0]=='1'){
displayAll(infile, stdout, bankTree.root);
break;
}
else if(op[0]=='2'){
printf("please input the name of file:\n");
scanf("%s",name);
FILE *t=fopen(name,"w+");
displayAll(infile, t,bankTree.root);
fclose(t);
break;
}
else
printf("please choose one of the two\n");
}
break;
}
else if(op[0]=='2'){
printf("please input the user's account:\n");
scanf("%d", &useracc);
Index tmp;
tmp.account=useracc;
avlNode * find=bankTree.findValue(tmp);//avl成員函數,修改
Item user;
findUser(infile,find,user);
Check(user,currentmonth);
break;
}
else
printf("select one of the two\n");
}
}
else if (op[0]=='5')
{
printf("please enter the new interest of fixed and unfixed:\n");
scanf("%lf", &interestForFix);
scanf("%lf", &interestForUnfix);
}
else if (op[0]=='6')
{
int useracc;
printf("please input the user's account:\n");
scanf("%d", &useracc);
Index tmp;
tmp.account=useracc;
avlNode * find=bankTree.findValue(tmp);//avl成員函數,修改
Item user;
FILE * infile=fopen("database.txt","r+");
findUser(infile,find,user);
while(1){
printf("please input a new password\n");
scanf("%d",&user.password);
if(user.password>=1000000)
printf("please input a password within 6 digits\n");
else
break;
}
user.Fout((find->value).pos,infile);
fflush(infile);
printf("password change is successful\n");
}
else if(op[0]=='7')
{
FILE* e=fopen("index.txt","w+");
ReBuildIndex(e, bankTree.root);//存儲一天的信息變化
fclose(e);
exit(1);
}
else if(op[0]=='8'){
ChangeInterestTxt(adaccount,adpassword,interestForFix,interestForUnfix,currentmonth);
break;
}
else
{
printf("please choose the right service:\n");
}
printf("please choose your operation:\n");
printf("1.changeTime\n");
printf("2.add user\n");
printf("3.delete user\n");
printf("4.check user\n");
printf("5.change the interest\n");
printf("6.change the pass word\n");
printf("7. end the operations\n");
printf("8. leave\n");
scanf("%s",op);
}
}//end else
}//end while of interface
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -