diff --git a/account.c b/account.c index 4a99369..eb85def 100644 --- a/account.c +++ b/account.c @@ -6,15 +6,15 @@ extern STACCOUNT g_astAccounts[]; extern int g_iAccCount; -/* 函数功能:处理用户的创建账户操作 - 思考处理步骤,写到函数体内注释 - * 参数:无 - * 存款信息要写入全局变量g_astAccounts中 - * 返回值:无 - * 存款失败怎么处理? +/* 鍑芥暟鍔熻兘锛氬鐞嗙敤鎴风殑鍒涘缓璐︽埛鎿嶄綔 + 鎬濊冨鐞嗘楠わ紝鍐欏埌鍑芥暟浣撳唴娉ㄩ噴 + * 鍙傛暟锛氭棤 + * 瀛樻淇℃伅瑕佸啓鍏ュ叏灞鍙橀噺g_astAccounts涓 + * 杩斿洖鍊硷細鏃 + * 瀛樻澶辫触鎬庝箞澶勭悊锛 */ void InitAdminAccount() { - printf("初始化默认管理员账户"); + printf("鍒濆鍖栭粯璁ょ鐞嗗憳璐︽埛"); g_astAccounts[0].id = 1000; strcpy(g_astAccounts[0].name, "admin"); g_astAccounts[0].balance = 0.0; @@ -25,73 +25,73 @@ void InitAdminAccount() { void CreateAccount(int quanxian) { - // (1)合法性检查 + // (1)鍚堟硶鎬ф鏌 if(MAX_ACCOUNTS < g_iAccCount) { - printf("账户数量已达上限!\n"); + printf("璐︽埛鏁伴噺宸茶揪涓婇檺!\n"); return; } - // (2)定义局部变量(函数内使用的变量) - STACCOUNT stNewAcc; //账户变量,结构体变量定义 - //char cInput[NAME_LEN]; //接输入的名字字符串 + // (2)瀹氫箟灞閮ㄥ彉閲忥紙鍑芥暟鍐呬娇鐢ㄧ殑鍙橀噺锛 + STACCOUNT stNewAcc; //璐︽埛鍙橀噺锛岀粨鏋勪綋鍙橀噺瀹氫箟 + //char cInput[NAME_LEN]; //鎺ヨ緭鍏ョ殑鍚嶅瓧瀛楃涓 - // (3)功能实现 - printf("请输入姓名(最多30个字符): "); + // (3)鍔熻兘瀹炵幇 + printf("璇疯緭鍏ュ鍚(鏈澶30涓瓧绗): "); - //这里有风险,怎么改进? + //杩欓噷鏈夐闄╋紝鎬庝箞鏀硅繘锛 scanf("%30s", stNewAcc.name); - //stNewAcc.name[NAME_LEN - 1] = '\0'; // 确保null终止 - //输密码 + //stNewAcc.name[NAME_LEN - 1] = '\0'; // 纭繚null缁堟 + //杈撳瘑鐮 int temp_password; while (1) { - printf("请输入密码\n"); + printf("璇疯緭鍏ュ瘑鐮乗n"); scanf("%d",&temp_password); if (999990) { break; } - printf("?你存给我存个负的?重新说存多少"); + printf("锛熶綘瀛樼粰鎴戝瓨涓礋鐨勶紵閲嶆柊璇村瓨澶氬皯"); } - printf("请输入密码"); + printf("璇疯緭鍏ュ瘑鐮"); while (1) { scanf("%d",&temp_password); if (g_astAccounts[FindAccount(id)].password==temp_password) { @@ -37,33 +37,33 @@ void Deposit(int id) else { { - printf("密码错误,请重新输入"); + printf("瀵嗙爜閿欒锛岃閲嶆柊杈撳叆"); } } } } -/* 函数功能:处理用户的取款操作 - 需要什么步骤? - * 参数:无 - * 取款后,账户信息要写入全局变量g_astAccounts中 - * 返回值:无 - * 取款失败怎么处理? +/* 鍑芥暟鍔熻兘锛氬鐞嗙敤鎴风殑鍙栨鎿嶄綔 + 闇瑕佷粈涔堟楠わ紵 + * 鍙傛暟锛氭棤 + * 鍙栨鍚庯紝璐︽埛淇℃伅瑕佸啓鍏ュ叏灞鍙橀噺g_astAccounts涓 + * 杩斿洖鍊硷細鏃 + * 鍙栨澶辫触鎬庝箞澶勭悊锛 */ void Withdraw(int id) { int amount; int temp_password; while (1) { - printf("请输入取款金额"); + printf("璇疯緭鍏ュ彇娆鹃噾棰"); scanf("%d",&amount); if (amount>0) { break; } - printf("?取款怎么能取负的呢"); + printf("锛熷彇娆炬庝箞鑳藉彇璐熺殑鍛"); } while (1) { - printf("请输入密码"); + printf("璇疯緭鍏ュ瘑鐮"); scanf("%d",&temp_password); if (g_astAccounts[FindAccount(id)].password==temp_password) { if (g_astAccounts[FindAccount(id)].balance>amount) { @@ -74,27 +74,27 @@ void Withdraw(int id) return; } else { - printf("有那么多钱吗你就取?\n"); + printf("鏈夐偅涔堝閽卞悧浣犲氨鍙栵紵\n"); QueryBalance(id); return; } } else { - printf("密码错误,请重新输入"); + printf("瀵嗙爜閿欒锛岃閲嶆柊杈撳叆"); } } } -/* 函数功能:处理用户查询余额操作 - 需要什么步骤? - * 参数:无 - * 查询后全局变量是否需要变化? - * 返回值:无 - * 查询失败怎么处理? +/* 鍑芥暟鍔熻兘锛氬鐞嗙敤鎴锋煡璇綑棰濇搷浣 + 闇瑕佷粈涔堟楠わ紵 + * 鍙傛暟锛氭棤 + * 鏌ヨ鍚庡叏灞鍙橀噺鏄惁闇瑕佸彉鍖栵紵 + * 杩斿洖鍊硷細鏃 + * 鏌ヨ澶辫触鎬庝箞澶勭悊锛 */ void QueryBalance(int id) { - printf("你现在还有%f块\n",g_astAccounts[FindAccount(id)].balance); + printf("浣犵幇鍦ㄨ繕鏈%f鍧梊n",g_astAccounts[FindAccount(id)].balance); return; } diff --git a/utils.c b/utils.c index be8ea24..bc6049f 100644 --- a/utils.c +++ b/utils.c @@ -13,7 +13,7 @@ int GetInputInt(const char *prompt) printf("%s", prompt); while(scanf("%d", &value) != 1) { ClearInput(); - printf("输入错误,请重新输入: "); + printf("杈撳叆閿欒锛岃閲嶆柊杈撳叆: "); } return value; } @@ -24,7 +24,7 @@ double GetInputDouble(const char *prompt) printf("%s", prompt); while(scanf("%lf", &value) != 1) { ClearInput(); - printf("输入错误,请重新输入: "); + printf("杈撳叆閿欒锛岃閲嶆柊杈撳叆: "); } return value; }