Linux下c语言实现通讯录,学生通讯录管理系统linux下C语言

程序代码

#include

#include

#include

#include

#define LEN sizeof(struct student)

struct student

{

char xh[13+1];

char xm[20+1];

char szbj[10+1];

char xb[2+1];

char sjhm[11+1];

char zz[30+1];

char bz[20+1];

struct student *next;

};

void face(void)

{

printf("\n");

printf("\t\t\t 1.-新建or更改记录-\n");

printf("\t\t\t 2.----查询记录----\n");

printf("\t\t\t 3.----删除记录----\n");

printf("\t\t\t 4.---保存并退出---\n");

printf("\t\t\t 5.-----退出-------\n");

printf("\t\t\t by someone \n");

printf("\n");

}

void print(struct student *head)

{

struct student *p;

p=head;

system("CLS");

if(head!=NULL)

do

{

printf("学号:%s\n",p->xh);

printf("姓名:%s\n",p->xm);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个使用C语言实现通讯录管理系统的示例: ```c #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_CONTACTS 100 typedef struct { char name[50]; char phone[20]; char qq[20]; } Contact; Contact contacts[MAX_CONTACTS]; int numContacts = 0; void addContact() { if (numContacts >= MAX_CONTACTS) { printf("通讯录已满,无法添加新联系人。\n"); return; } Contact newContact; printf("请输入联系人姓名:"); scanf("%s", newContact.name); printf("请输入联系人电话号码:"); scanf("%s", newContact.phone); printf("请输入联系人QQ号码:"); scanf("%s", newContact.qq); contacts[numContacts] = newContact; numContacts++; printf("联系人添加成功!\n"); } void deleteContact() { if (numContacts == 0) { printf("通讯录为空,无法删除联系人。\n"); return; } char name[50]; printf("请输入要删除的联系人姓名:"); scanf("%s", name); int foundIndex = -1; for (int i = 0; i < numContacts; i++) { if (strcmp(contacts[i].name, name) == 0) { foundIndex = i; break; } } if (foundIndex == -1) { printf("未找到该联系人。\n"); return; } for (int i = foundIndex; i < numContacts - 1; i++) { contacts[i] = contacts[i + 1]; } numContacts--; printf("联系人删除成功!\n"); } void searchContact() { if (numContacts == 0) { printf("通讯录为空,无法查找联系人。\n"); return; } char keyword[50]; printf("请输入要查找的关键字:"); scanf("%s", keyword); int found = 0; for (int i = 0; i < numContacts; i++) { if (strstr(contacts[i].name, keyword) != NULL || strstr(contacts[i].phone, keyword) != NULL || strstr(contacts[i].qq, keyword) != NULL) { printf("姓名:%s\n", contacts[i].name); printf("电话号码:%s\n", contacts[i].phone); printf("QQ号码:%s\n", contacts[i].qq); printf("\n"); found = 1; } } if (!found) { printf("未找到匹配的联系人。\n"); } } void modifyContact() { if (numContacts == 0) { printf("通讯录为空,无法修改联系人。\n"); return; } char name[50]; printf("请输入要修改的联系人姓名:"); scanf("%s", name); int foundIndex = -1; for (int i = 0; i < numContacts; i++) { if (strcmp(contacts[i].name, name) == 0) { foundIndex = i; break; } } if (foundIndex == -1) { printf("未找到该联系人。\n"); return; } Contact modifiedContact; printf("请输入新的联系人姓名:"); scanf("%s", modifiedContact.name); printf("请输入新的联系人电话号码:"); scanf("%s", modifiedContact.phone); printf("请输入新的联系人QQ号码:"); scanf("%s", modifiedContact.qq); contacts[foundIndex] = modifiedContact; printf("联系人修改成功!\n"); } void browseContacts() { if (numContacts == 0) { printf("通讯录为空。\n"); return; } printf("通讯录中的联系人:\n"); for (int i = 0; i < numContacts; i++) { printf("姓名:%s\n", contacts[i].name); printf("电话号码:%s\n", contacts[i].phone); printf("QQ号码:%s\n", contacts[i].qq); printf("\n"); } } void clearContacts() { numContacts = 0; printf("通讯录已清空。\n"); } void sortContacts() { if (numContacts == 0) { printf("通讯录为空,无法排序。\n"); return; } for (int i = 0; i < numContacts - 1; i++) { for (int j = 0; j < numContacts - i - 1; j++) { if (strcmp(contacts[j].name, contacts[j + 1].name) > 0) { Contact temp = contacts[j]; contacts[j] = contacts[j + 1]; contacts[j + 1] = temp; } } } printf("通讯录已按姓名排序。\n"); } int main() { int choice; while (1) { printf("通讯录管理系统\n"); printf("1. 添加联系人\n"); printf("2. 删除联系人\n"); printf("3. 查找联系人\n"); printf("4. 修改联系人\n"); printf("5. 浏览联系人\n"); printf("6. 清空通讯录\n"); printf("7. 按姓名排序\n"); printf("0. 退出\n"); printf("请输入操作编号:"); scanf("%d", &choice); switch (choice) { case 1: addContact(); break; case 2: deleteContact(); break; case 3: searchContact(); break; case 4: modifyContact(); break; case 5: browseContacts(); break; case 6: clearContacts(); break; case 7: sortContacts(); break; case 0: printf("感谢使用通讯录管理系统,再见!\n"); exit(0); default: printf("无效的操作编号,请重新输入。\n"); break; } printf("\n"); } return 0; } ``` 该通讯录管理系统具有以下功能: 1. 添加联系人:输入联系人的姓名、电话号码和QQ号码,将其添加到通讯录中。 2. 删除联系人:根据联系人的姓名,从通讯录中删除对应的联系人。 3. 查找联系人:根据关键字,在通讯录中查找匹配的联系人,并显示其姓名、电话号码和QQ号码。 4. 修改联系人:根据联系人的姓名,修改对应联系人的姓名、电话号码和QQ号码。 5. 浏览联系人:显示通讯录中所有联系人的姓名、电话号码和QQ号码。 6. 清空通讯录:清空通讯录中的所有联系人。 7. 按姓名排序:按照联系人的姓名对通讯录进行排序。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值