?? egewg.cpp
字號:
bool deleteUser(FILE* data, avlTree* root)
{
printf("請輸入想要刪除的帳號:");
int acc;
scanf("%d",&acc);
Index tmp;//臨時查找變量,account是被查的值,pos內容不關心
tmp.account=acc;
avlNode *tmp1;
tmp1=root->findValue(tmp);//找到變量
if(!tmp1){
printf("沒有該帳號\n");
return false;
}
if(root->remove(tmp)){//從索引中刪除
Item tmp2;
tmp2.account=999999999;tmp2.password=0;tmp2.deposit=0;tmp2.type='u';tmp2.month=0;
tmp2.Fout( (tmp1->value).pos,data);
printf("刪除成功\n");
return true;
}
else{
printf("刪除出現錯誤\n");
return false;
}
}
bool addUser(FILE* data, avlTree* root, int curmon)
{
printf("請輸入新增帳戶名稱:");
int acc;
scanf("%d",&acc);
Index tmp;//臨時查找變量,account是被查的值,pos內容不關心
tmp.account=acc;
avlNode *tmp1;
tmp1=root->findValue(tmp);//找到變量
if(tmp1){
printf("已經存在該帳號,返回上一級\n");
return false;
}
Item tmp2;//新增加的帳號
int tmp3;//確認密碼
while(1){
printf("請輸入密碼:");
scanf("%d", tmp2.password);
printf"請再次輸入密碼:");
scanf("%d",tmp3);
if(tmp2.password==tmp3){
printf("密碼設置成功\n");
break;
}
else
printf("兩次密碼設置不一致\n");
}
while(1){
printf("請輸入用戶類型,f為定期存款,u為活期:");
char tmp4;
scanf("%c",&tmp4);
if(tmp4=='f' || tmp4=='u'){
tmp2.type=tmp4;
break;
}
else
printf("類型錯誤\n");
}
tmp2.account=acc;
tmp2.deposit=0;
tmp2.month=curmon;
fseek(data,0,SEEK_END);//加在最后
int pos=ftell(data)/LENGTH;//應該的位置,LENGTH在Item里定義
tmp2.Fout(pos,data);//寫入database
//插入avl樹中
Index tmp5;
tmp5.account=acc;
tmp5.pos=pos;
root->add(tmp5);
printf("插入成功");
return true;
}
else{
printf("刪除出現錯誤\n");
return false;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -