编写c语言程序,制作一个简单的美发沙龙会员管理系统
时间: 2024-03-01 11:51:51 浏览: 76
cs 理发店会员管理系统
4星 · 用户满意度95%
好的,我可以为您提供一个简单的美发沙龙会员管理系统的C语言程序。
```c
#include <stdio.h>
#include <string.h>
#define MAX_MEMBERS 100
// 会员结构体
typedef struct {
char name[20]; // 姓名
char phone_number[12]; // 手机号码
int points; // 积分
} Member;
// 会员数组
Member members[MAX_MEMBERS];
int num_members = 0;
// 显示主菜单
void show_menu() {
printf("欢迎使用美发沙龙会员管理系统\n");
printf("1. 添加会员\n");
printf("2. 修改会员信息\n");
printf("3. 删除会员\n");
printf("4. 查询会员信息\n");
printf("5. 显示所有会员信息\n");
printf("6. 退出系统\n");
printf("请选择操作:");
}
// 添加会员
void add_member() {
if (num_members >= MAX_MEMBERS) {
printf("会员数量已达上限,无法添加新会员!\n");
return;
}
Member new_member;
printf("请输入会员姓名:");
scanf("%s", new_member.name);
printf("请输入会员手机号码:");
scanf("%s", new_member.phone_number);
new_member.points = 0;
members[num_members++] = new_member;
printf("添加会员成功!\n");
}
// 修改会员信息
void modify_member() {
char phone_number[12];
printf("请输入要修改的会员手机号码:");
scanf("%s", phone_number);
int index = -1;
for (int i = 0; i < num_members; i++) {
if (strcmp(members[i].phone_number, phone_number) == 0) {
index = i;
break;
}
}
if (index == -1) {
printf("找不到该会员!\n");
return;
}
Member *member = &members[index];
printf("请输入会员姓名(原姓名:%s):", member->name);
scanf("%s", member->name);
printf("请输入会员手机号码(原手机号码:%s):", member->phone_number);
scanf("%s", member->phone_number);
printf("修改会员信息成功!\n");
}
// 删除会员
void delete_member() {
char phone_number[12];
printf("请输入要删除的会员手机号码:");
scanf("%s", phone_number);
int index = -1;
for (int i = 0; i < num_members; i++) {
if (strcmp(members[i].phone_number, phone_number) == 0) {
index = i;
break;
}
}
if (index == -1) {
printf("找不到该会员!\n");
return;
}
for (int i = index; i < num_members - 1; i++) {
members[i] = members[i + 1];
}
num_members--;
printf("删除会员成功!\n");
}
// 查询会员信息
void search_member() {
char phone_number[12];
printf("请输入要查询的会员手机号码:");
scanf("%s", phone_number);
int index = -1;
for (int i = 0; i < num_members; i++) {
if (strcmp(members[i].phone_number, phone_number) == 0) {
index = i;
break;
}
}
if (index == -1) {
printf("找不到该会员!\n");
return;
}
Member *member = &members[index];
printf("姓名:%s\n", member->name);
printf("手机号码:%s\n", member->phone_number);
printf("积分:%d\n", member->points);
}
// 显示所有会员信息
void show_all_members() {
printf("所有会员信息:\n");
printf("%-10s%-15s%-10s\n", "姓名", "手机号码", "积分");
for (int i = 0; i < num_members; i++) {
Member *member = &members[i];
printf("%-10s%-15s%-10d\n", member->name, member->phone_number, member->points);
}
}
int main() {
int choice;
do {
show_menu();
scanf("%d", &choice);
switch (choice) {
case 1:
add_member();
break;
case 2:
modify_member();
break;
case 3:
delete_member();
break;
case 4:
search_member();
break;
case 5:
show_all_members();
break;
case 6:
printf("谢谢使用美发沙龙会员管理系统,再见!\n");
break;
default:
printf("无效的选择,请重新选择!\n");
break;
}
} while (choice != 6);
return 0;
}
```
这个程序实现了以下功能:
1. 添加会员
2. 修改会员信息
3. 删除会员
4. 查询会员信息
5. 显示所有会员信息
6. 退出系统
您可以根据实际需要进行修改和完善。
阅读全文