学生通讯录管理系统的设计与实现(c语言实现)

我也是初学者,希望大家一起成长啊,有什么不会的题可以一起研究。

一,需求分析

1,输入数据建立通讯录。

2,查询通讯录中满足要求的信息。

3,插入新的通讯录信息。

4,删除不需要的通讯录信息。

5,查看所有的通讯录信息。

 

#define DATATYPE3 char 
#include <malloc.h>
#include <stdio.h>
#define null 0
#include <string.h>
typedef struct node{
	DATATYPE3 study[20],name[20],num[20];
	struct node *next;
}LINKLIST;
LINKLIST *init() /*单链表初始化函数*/ 
{
	LINKLIST *head; 
	head=(LINKLIST *)malloc(sizeof(LINKLIST));
	head->next=null; 
 	return head; 
}
LINKLIST *creat(){//尾插入法建立单链表,输入0结束
	//char s,m,n;
	DATATYPE3 study[20],name[20],num[20];
	int b,i,j;
	LINKLIST *head,*p,*q;
	head=init();
	q=head;
	printf("请输入学生个数:");
	scanf("%d",&b);
	for(i=0;i<b;i++)
	{
		p=(LINKLIST*)malloc(sizeof(LINKLIST));
		printf("请输入学生%d学号,姓名,电话号码:",i+1);
		//scan
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
好的,以下是一个简单的用C语言实现学生通讯录系统,可以让用户自己输入学生的信息并随意插入到通讯录中: ```c #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_NAME_LEN 30 #define MAX_PHONE_LEN 15 struct Student { char name[MAX_NAME_LEN]; char phone[MAX_PHONE_LEN]; struct Student *next; }; struct Student* createStudent(char name[], char phone[]) { struct Student* newStudent = (struct Student*)malloc(sizeof(struct Student)); strcpy(newStudent->name, name); strcpy(newStudent->phone, phone); newStudent->next = NULL; return newStudent; } void insertStudent(struct Student** head, char name[], char phone[], int pos) { struct Student* newStudent = createStudent(name, phone); if (*head == NULL) { *head = newStudent; return; } if (pos == 1) { newStudent->next = *head; *head = newStudent; return; } struct Student* curr = *head; for (int i = 1; i < pos - 1 && curr != NULL; i++) { curr = curr->next; } if (curr == NULL) { printf("Error: Invalid position\n"); return; } newStudent->next = curr->next; curr->next = newStudent; } void printStudent(struct Student* student) { printf("%-30s %-15s\n", student->name, student->phone); } void printStudentList(struct Student* head) { if (head == NULL) { printf("List is empty\n"); return; } struct Student* curr = head; printf("%-30s %-15s\n", "Name", "Phone"); while (curr != NULL) { printStudent(curr); curr = curr->next; } } int main() { struct Student* head = NULL; char name[MAX_NAME_LEN], phone[MAX_PHONE_LEN]; int n, pos; printf("Enter the number of students: "); scanf("%d", &n); for (int i = 1; i <= n; i++) { printf("Enter student %d's name: ", i); scanf("%s", name); printf("Enter student %d's phone number: ", i); scanf("%s", phone); insertStudent(&head, name, phone, i); } printStudentList(head); printf("Enter position to insert new student: "); scanf("%d", &pos); printf("Enter new student's name: "); scanf("%s", name); printf("Enter new student's phone number: "); scanf("%s", phone); insertStudent(&head, name, phone, pos); printStudentList(head); return 0; } ``` 在这个程序中,我们用 `struct Student` 来表示学生的信息,其中 `name` 存储学生的姓名,`phone` 存储学生的电话号码,`next` 存储指向下一个学生的指针。我们用 `createStudent()` 函数来创建学生信息,用 `insertStudent()` 函数来插入学生信息,用 `printStudent()` 函数来输出单个学生的信息,用 `printStudentList()` 函数来输出整个学生通讯录。在 `main()` 函数中,我们先让用户输入学生个数和每个学生的姓名和电话号码,然后再让用户输入要插入的新学生的位置和姓名、电话号码,最后输出修改后的学生通讯录

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

未来的软件工程师2

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值