在外求学,小女子请教C高手们,学校人员管理程序。请大家帮帮忙。。
答案:3 悬赏:0 手机版
解决时间 2021-02-02 12:33
- 提问者网友:轻浮
- 2021-02-02 04:43
在外求学,小女子请教C高手们,学校人员管理程序。请大家帮帮忙。。
最佳答案
- 五星知识达人网友:鸽屿
- 2021-02-02 05:39
调试过了,可以运行,使用VC6.0编译
#include
#include
#include
struct member
{
char name[20], type, Class[80];
char Major[80], Class_name[80], occupation[80];
int E_score, ID, P_score, graduation;
member *next;
};
int judgeName(char *j_name, member *h);
member *Add(member *head)
{
member *node;
node = new member;
int n;
printf("-----------------------------\n");
printf(">name:");
scanf("%s", node->name);
if((n = judgeName(node->name, head)) == 1)
{
delete node;
return head;
}
printf(">ID:");
scanf("%d", &node->ID);
if(node->ID > 999 || node->ID < 1)
{
printf("ID must be 1-999\n");
delete node;
return head;
}
printf(">Member type(s/p/a):");
scanf("%1s", &node->type);
printf("-----------------------------\n");
switch(node->type)
{
case 's':
printf(">Class attending:");
scanf("%s", node->Class);
printf(">Exam score:");
scanf("%d", &node->E_score);
printf(">Project score:");
scanf("%d", &node->P_score);
break;
case 'p':
printf(">Major:");
scanf("%s", node->Major);
printf(">Class name:");
scanf("%s", node->Class_name);
break;
case 'a':
printf(">Year of graduation:");
scanf("%d", &node->graduation);
printf(">Current occupation:");
scanf("%s", node->occupation);
break;
default:
printf("未知操作\n");
delete node;
return head;
}
printf("-----------------------------\n");
node->next = head;
head = node;
return head;
}
member *Delete(member *head)
{
member *preNode = NULL, *curNode = head;
char del_name[20];
printf("Input a member\'s name:");
scanf("%s", del_name);
while (curNode && strcmp(curNode->name, del_name))
{
preNode = curNode;
curNode = curNode->next;
}
if (curNode == NULL)
{
printf("Member \"%s\" is not found.\n", del_name);
return head;
}
else
printf("The member \"%s\" is deleted.\n", del_name);
if(preNode == NULL)
head = head->next;
else
preNode->next = curNode->next;
delete curNode;
return head;
}
void Select(member *head)
{
char sel_name[20];
printf("Input a member\'s name:");
scanf("%s", sel_name);
while(head)
{
if(!strcmp(head->name, sel_name))
{
printf("Member type:%c\nName:%s\nID:%d\n", head->type, head->name, head->ID);
switch(head->type)
{
case 's':
printf("Class attending:%s\nExam score:%d\nProject score:%d\n",
head->Class, head->E_score, head->P_score);
break;
case 'p':
printf("Major:%s\nClass name:%s\n", head->Major, head->Class_name);
break;
case 'a':
printf(">Year of graduation:%d\nCurrent occupation:%s\n", head->graduation, head->occupation);
break;
}
}
head = head->next;
}
}
void Display(member *head)
{
char dis_type;
printf("input a type:");
scanf("%1s", &dis_type);
printf("------------------------------------------------\nAlumni List\n");
switch(dis_type)
{
case 's':
printf("Name\tID\tClass attending\tExam score\tProject score\n");
break;
case 'p':
printf("Name\tID\tMajor\tClass name:\n");
break;
case 'a':
printf("Name\tID\tGraduation\tCurrent Occupation\n");
break;
}
printf("================================================\n");
while(head)
{
if(dis_type == head->type)
{
switch(head->type)
{
case 's':
printf("%s\t%d\t%s%d%d\n", head->name, head->ID,
head->Class, head->E_score, head->P_score);
break;
case 'p':
printf("%s\t%d\t%s\t%s\n", head->name, head->ID, head->Major, head->Class_name);
break;
case 'a':
printf("%s\t%d\t%d\t%s\n", head->name, head->ID, head->graduation, head->occupation);
break;
}
}
head = head->next;
}
printf("------------------------------------------------\n");
}
int judgeName(char *j_name, member *h)
{
if(h == NULL)
return 0;
while(h)
{
if(!strcmp(h->name, j_name))
{
printf("Name already exists\n");
return 1;
}
h = h->next;
}
return 0;
}
void main()
{
int n;
member *head = NULL;
while (1)
{
printf("------------------ \nMenu\n\n");
printf("\t\t1.Add a member \n\t\t2.Delete a member\n\t\t3.Find a member\n\t\t4.Display members \n\t\t5.Exit \n");
printf("------------------\n");
printf(">Select a number: ");
scanf("%d", &n);
switch (n)
{
case 1:
head = Add(head);
break;
case 2:
head = Delete(head);
break;
case 3:
Select(head);
break;
case 4:
Display(head);
break;
case 5:
exit(0);
default:
printf("未知操作\n");
}
}
}
#include
#include
#include
struct member
{
char name[20], type, Class[80];
char Major[80], Class_name[80], occupation[80];
int E_score, ID, P_score, graduation;
member *next;
};
int judgeName(char *j_name, member *h);
member *Add(member *head)
{
member *node;
node = new member;
int n;
printf("-----------------------------\n");
printf(">name:");
scanf("%s", node->name);
if((n = judgeName(node->name, head)) == 1)
{
delete node;
return head;
}
printf(">ID:");
scanf("%d", &node->ID);
if(node->ID > 999 || node->ID < 1)
{
printf("ID must be 1-999\n");
delete node;
return head;
}
printf(">Member type(s/p/a):");
scanf("%1s", &node->type);
printf("-----------------------------\n");
switch(node->type)
{
case 's':
printf(">Class attending:");
scanf("%s", node->Class);
printf(">Exam score:");
scanf("%d", &node->E_score);
printf(">Project score:");
scanf("%d", &node->P_score);
break;
case 'p':
printf(">Major:");
scanf("%s", node->Major);
printf(">Class name:");
scanf("%s", node->Class_name);
break;
case 'a':
printf(">Year of graduation:");
scanf("%d", &node->graduation);
printf(">Current occupation:");
scanf("%s", node->occupation);
break;
default:
printf("未知操作\n");
delete node;
return head;
}
printf("-----------------------------\n");
node->next = head;
head = node;
return head;
}
member *Delete(member *head)
{
member *preNode = NULL, *curNode = head;
char del_name[20];
printf("Input a member\'s name:");
scanf("%s", del_name);
while (curNode && strcmp(curNode->name, del_name))
{
preNode = curNode;
curNode = curNode->next;
}
if (curNode == NULL)
{
printf("Member \"%s\" is not found.\n", del_name);
return head;
}
else
printf("The member \"%s\" is deleted.\n", del_name);
if(preNode == NULL)
head = head->next;
else
preNode->next = curNode->next;
delete curNode;
return head;
}
void Select(member *head)
{
char sel_name[20];
printf("Input a member\'s name:");
scanf("%s", sel_name);
while(head)
{
if(!strcmp(head->name, sel_name))
{
printf("Member type:%c\nName:%s\nID:%d\n", head->type, head->name, head->ID);
switch(head->type)
{
case 's':
printf("Class attending:%s\nExam score:%d\nProject score:%d\n",
head->Class, head->E_score, head->P_score);
break;
case 'p':
printf("Major:%s\nClass name:%s\n", head->Major, head->Class_name);
break;
case 'a':
printf(">Year of graduation:%d\nCurrent occupation:%s\n", head->graduation, head->occupation);
break;
}
}
head = head->next;
}
}
void Display(member *head)
{
char dis_type;
printf("input a type:");
scanf("%1s", &dis_type);
printf("------------------------------------------------\nAlumni List\n");
switch(dis_type)
{
case 's':
printf("Name\tID\tClass attending\tExam score\tProject score\n");
break;
case 'p':
printf("Name\tID\tMajor\tClass name:\n");
break;
case 'a':
printf("Name\tID\tGraduation\tCurrent Occupation\n");
break;
}
printf("================================================\n");
while(head)
{
if(dis_type == head->type)
{
switch(head->type)
{
case 's':
printf("%s\t%d\t%s%d%d\n", head->name, head->ID,
head->Class, head->E_score, head->P_score);
break;
case 'p':
printf("%s\t%d\t%s\t%s\n", head->name, head->ID, head->Major, head->Class_name);
break;
case 'a':
printf("%s\t%d\t%d\t%s\n", head->name, head->ID, head->graduation, head->occupation);
break;
}
}
head = head->next;
}
printf("------------------------------------------------\n");
}
int judgeName(char *j_name, member *h)
{
if(h == NULL)
return 0;
while(h)
{
if(!strcmp(h->name, j_name))
{
printf("Name already exists\n");
return 1;
}
h = h->next;
}
return 0;
}
void main()
{
int n;
member *head = NULL;
while (1)
{
printf("------------------ \nMenu\n\n");
printf("\t\t1.Add a member \n\t\t2.Delete a member\n\t\t3.Find a member\n\t\t4.Display members \n\t\t5.Exit \n");
printf("------------------\n");
printf(">Select a number: ");
scanf("%d", &n);
switch (n)
{
case 1:
head = Add(head);
break;
case 2:
head = Delete(head);
break;
case 3:
Select(head);
break;
case 4:
Display(head);
break;
case 5:
exit(0);
default:
printf("未知操作\n");
}
}
}
全部回答
- 1楼网友:狂恋
- 2021-02-02 07:16
这不就是一个 学生信息管理系统么 我有源代码 给楼主看看吧 希望可以帮上你的忙 详细代码:http://www.henrysyw.cn/article.asp?id=1078 如果楼主觉得这个网站好 请推荐给你的朋友 多谢
- 2楼网友:北方的南先生
- 2021-02-02 07:02
看了你的名字,决定不帮了。不能害了你。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯