```c #include <stdio.h> #include <string.h> int main() { // 初始密码 char password[] = "123456"; char input; char newPassword[7]; printf("欢迎使用密码系统!\n"); while (1) { printf("请输入操作命令(1:密码确认 2:设置密码 3:显示密码 4:重置密码 0:退出): "); scanf(" %c", &input); switch (input) { case '1': printf("请输入密码: "); scanf("%s", newPassword); if (strcmp(newPassword, password) == 0) { printf("密码正确\n"); } else { printf("密码错误\n"); } break; case '2': printf("请输入新密码: "); scanf("%s", newPassword); strcpy(password, newPassword); printf("设置正确\n"); break; case '3': printf("当前密码是: %s\n", password); break; case '4': strcpy(password, "000000"); printf("密码已重置为 000000\n"); break; case '0': printf("系统退出\n"); return 0; default: printf("输入错误请重新输入\n"); } } return 0; } ``` 额外注意逻辑点: 1. 密码存储应注意安全性,避免明文存储。 2. 输入密码时,可考虑对输入进行过滤和验证。 3. 代码中的密码处理较为简单,实际应用中需考虑更多复杂情况。 [2025-03-28 10:43:55 | AI写代码神器 | 414点数解答]