使用道具 举报
本版积分规则 发表回复 回帖并转播 回帖后跳转到最后一页
中级红客
2024-5-5
2024-3-24
2024-3-16
2024-2-18
2024-1-20
中国红客联盟公众号
联系站长QQ:5520533
cpp
#include <iostream>
#include <iomanip>
#include <string>
void displayMenu() {
std::cout << "=== 红盟用户功能菜单 ===" << std::endl;
std::cout << "1. 查询个人信息" << std::endl;
std::cout << "2. 修改密码" << std::endl;
std::cout << "3. 查看消息" << std::endl;
std::cout << "4. 发送消息" << std::endl;
std::cout << "5. 退出" << std::endl;
std::cout << "=====================" << std::endl;
std::cout << "请输入选项:";
}
void showUserInfo() {
// 此处为示例,可以根据实际需求添加个人信息的显示
std::cout << "=== 个人信息 ===" << std::endl;
std::cout << "用户名:user123" << std::endl;
std::cout << "邮箱:user123@example.com" << std::endl;
std::cout << "手机号码:1234567890" << std::endl;
std::cout << "================" << std::endl;
}
void changePassword() {
std::string newPassword;
std::cout << "请输入新密码:";
std::cin >> newPassword;
std::cout << "密码已修改为:" << newPassword << std::endl;
}
void viewMessages() {
// 此处为示例,可以根据实际需求添加消息的显示
std::cout << "=== 消息列表 ===" << std::endl;
std::cout << "1. 消息1" << std::endl;
std::cout << "2. 消息2" << std::endl;
std::cout << "3. 消息3" << std::endl;
std::cout << "===============" << std::endl;
}
void sendMessage() {
std::string message;
std::cout << "请输入消息内容:";
std::cin.ignore();
std::getline(std::cin, message);
std::cout << "消息已发送:" << message << std::endl;
}
int main() {
int choice;
do {
system("cls"); // 清屏命令,用于清除控制台上的内容
displayMenu();
std::cin >> choice;
switch (choice) {
case 1:
showUserInfo();
system("pause"); // 暂停命令,用于等待用户按任意键继续
break;
case 2:
changePassword();
system("pause");
break;
case 3:
viewMessages();
system("pause");
break;
case 4:
sendMessage();
system("pause");
break;
case 5:
std::cout << "已退出。" << std::endl;
break;
default:
std::cout << "无效的选项,请重新输入。" << std::endl;
system("pause");
break;
}
} while (choice != 5);
return 0;
}
该示例程序提供了一个简单的命令行界面,模拟了红盟用户的功能菜单。用户可以根据菜单选项选择不同的功能,包括查询个人信息、修改密码、查看消息和发送消息。用户输入选项后,程序将执行相应的操作,并在控制台上显示结果。程序在每次选择后暂停,以等待用户按下任意键继续操作。
使用道具 举报