呵呵
2024-12-07 20:43:17
发布于:浙江
#include <iostream>
#include <vector>
#include <string>
// 会员结构体
struct Member {
std::string name;
int level;
int contribution;
};
// 存储会员信息的向量
std::vector<Member> members;
// 注册会员函数
void registerMember(const std::string& name) {
Member newMember;
newMember.name = name;
newMember.level = 1;
newMember.contribution = 0;
members.push_back(newMember);
std::cout << name << " has been registered as a member of ACGO in the other world!" << std::endl;
}
// 显示会员信息函数
void displayMembers() {
std::cout << "ACGO Members in the Other World:" << std::endl;
for (const Member& member : members) {
std::cout << "Name: " << member.name << ", Level: " << member.level << ", Contribution: " << member.contribution << std::endl;
}
}
// 提升会员等级函数
void upgradeMemberLevel(const std::string& name, int contribution) {
for (Member& member : members) {
if (member.name == name) {
member.contribution += contribution;
if (member.contribution >= 100) {
member.level++;
std::cout << name << " has been upgraded to level " << member.level << "!" << std::endl;
}
return;
}
}
std::cout << name << " is not a member of ACGO in the other world." << std::endl;
}
int main() {
std::string name;
int choice, contribution;
while (true) {
std::cout << "ACGO in the Other World Menu:" << std::endl;
std::cout << "1. Register Member" << std::endl;
std::cout << "2. Display Members" << std::endl;
std::cout << "3. Upgrade Member Level" << std::endl;
std::cout << "4. Exit" << std::endl;
std::cout << "Enter your choice: ";
std::cin >> choice;
switch (choice) {
case 1:
std::cout << "Enter member name: ";
std::cin >> name;
registerMember(name);
break;
case 2:
displayMembers();
break;
case 3:
std::cout << "Enter member name: ";
std::cin >> name;
std::cout << "Enter contribution points: ";
std::cin >> contribution;
upgradeMemberLevel(name, contribution);
break;
case 4:
std::cout << "Exiting ACGO in the Other World." << std::endl;
return 0;
default:
std::cout << "Invalid choice. Please try again." << std::endl;
}
}
return 0;
}
全部评论 1
豪
1周前 来自 重庆
0
有帮助,赞一个