C语言题目

C语言题目,第1张

我曾经做过一个通讯录管理,希望你能用得上

通讯录管理

#include<stdio.h>

#include<malloc.h>

#include <string.h>

#include <conio.h>

#define NULL 0

#include<WINDOWS.h>

struct list

{

char name[30]

char phone[20]

char email[30]

char position[50]

char title[20]

struct list *next

} //个人信息

/**************************函数声明***************************/

void menu(struct list *head) //功能菜单

struct list *acces(struct list *head) //添加

void reword(struct list *re) //修改

void show(struct list *head)//显示

struct list *find(struct list *head) //查找

struct list *sort(struct list *head,struct list *insort) //排序

/************************功能菜单函数**************************/

void menu(struct list *head)

{ char op

do{

printf("\n\t\t***************************************************")

printf("\n\t\t*******欢迎使用本系统,请选择您所需要的服务:********")

printf("\n\t\t***************************************************")

printf("\n\t\t* Menu selection*")

printf("\n\t\t* 1.添加新联系人 *")

printf("\n\t\t* 2.显示联系人基本信息 *")

printf("\n\t\t* 3.查找联系人 *")

printf("\n\t\t* 4.退出本程序 *")

printf("\n\t\t***************************************************") //head=reword(head)修改函数

printf("\n请选择您所需要的服务:")

op=getch()

switch(op)

{

case '1':head=acces(head)

break

case '2':show(head)

break

case '3':head=find(head)

break

case '4':

break

default:

printf("\n\t\t\t输入错误!")

break

}

}

while(op!='4')

}

/**************************添加新联系人************************/

struct list *acces(struct list *head)

{

int i,n

char ch

struct list *pnew,*ptail //定义结构体指针变量

pnew=(struct list *)malloc(sizeof(struct list)) //创建新节点

ptail=pnew

printf("\n\t请输入需要添加的个数:")

scanf("%d",&n)

printf("\t\t\t请输入姓名:")

scanf("%s",pnew->name)//输入新成员姓名

printf("\t\t\t请输入电话号码:")scanf("%s",pnew->phone) //输入新成员电话号码

printf("\t\t\t请输入电子邮件:")scanf("%s",pnew->email) //输入新成员电子邮件

printf("\t\t\t请输入职务:")scanf("%s",pnew->position) //输入新成员职务

printf("\t\t\t请输入职称:")scanf("%s",pnew->title) //输入新成员职称

printf("\n")

pnew->next=NULL

head=sort(head,pnew)

for(i=1i<ni++)

{

pnew=(struct list *)malloc(sizeof(struct list))

printf("\t\t\t请输入姓名:")scanf("%s",pnew->name)

printf("\t\t\t请输入电话号码:")scanf("%s",pnew->phone)

printf("\t\t\t请输入电子邮件:")scanf("%s",pnew->email)

printf("\t\t\t请输入职务:")scanf("%s",pnew->position)

printf("\t\t\t请输入职称:")scanf("%s",pnew->title)

printf("\n")

pnew->next=NULL

head=sort(head,pnew)

}

printf("\n\t\t***************************************************")

printf("\n\t\t* 添加 成功*")

printf("\n\t\t* 返回主菜单*")

printf("\n\t\t***************************************************")

getch()

return(head)

}

/**************************显示学生信息************************/

void show(struct list *head)

{

struct list *p

p=head

if(NULL==p)

printf("没有联系人!")

else printf("\n姓名电话 Email职务 职称\n")

while(p!=NULL)

{

printf("%s\t%s\t\t%s\t\t%s\t\t%s\n",p->name,p->phone,p->email,p->position,p->title)

p=p->next

}

printf("\n显示完毕!")

}

/**************************查找学生信息菜单列表************************/

struct list *find(struct list *head)

{

struct list *find1(struct list *head)

struct list *find2(struct list *head)

struct list *find3(struct list *head)

struct list *find4(struct list *head)

struct list *find5(struct list *head)

char op

printf("\n\t\t***************************************************")

printf("\n\t\t* Menu selection*")

printf("\n\t\t* 1.查找联系人姓名 *")

printf("\n\t\t* 2.查找联系人电话号码 *")

printf("\n\t\t* 3.查找联系人电子邮件 *")

printf("\n\t\t* 4.查找联系人职务 *")

printf("\n\t\t* 5.查找联系人职称 *")

printf("\n\t\t* 6.退出本程序 *")

printf("\n\t\t***************************************************")

printf("\n\t\t\t请选择您所需要的服务:")

op=getch()

switch(op)

{

case '1':head=find1(head)

break

case '2':head=find2(head)

break

case '3':head=find3(head)

break

case '4':head=find4(head)

break

case '5':head=find5(head)

break

case '6':getchar()

break

default:

printf("\n输入错误!")

break

}

return head

}

/***************查找新联系人 一 姓名查找 *****************/

struct list *find1(struct list *head)

{

char fname[30]

struct list *p1,*p2,*p3

char ch

printf("\n请输入您要查找的联系人的姓名:")

scanf("%s",fname)

if (head==NULL)

{

printf("没有联系人!")

goto end

}

else p1=head

while(0!=strcmp(fname,p1->name)&&p1->next!=NULL)

{

p2=p1p1=p1->next

}

p3=p1

if(0==strcmp(fname,p1->name))

{

printf("\n姓名电话 Email职务 职称\n")

printf("%s\t%s\t\t%s\t\t%s\t\t%s\n",p3->name,p3->phone,p3->email,p3->position,p3->title)

printf("\n\t\t***************************************************")

printf("\n\t\t* Menu selection*")

printf("\n\t\t* 1.修改信息 *")

printf("\n\t\t* 2.继续查找联系人 *")

printf("\n\t\t* 3.删除当前联系人 *")

printf("\n\t\t* 4.返回主菜单 *")

printf("\n\t\t***************************************************")

printf("\n\t\t请选择您所需要的服务:")

ch=getch()

switch(ch)

{

case '1':reword(p1)

break

case '2':head=find(head)

break

case '3':

{

if(p1==head)head=p1->next

else p2->next=p1->next

printf("成功删除!")

}

break

case '4':void menu(struct list *head)

break

default:

printf("\n输入错误!")

break

}

}

else printf("没有找到!!!!")

end:

return(head)

}

/***************查找新联系人 二 电话查找 *****************/

struct list *find2(struct list *head)

{

char fphone[30]

struct list *p1,*p2,*p3

char ch

printf("\n请输入您要查找的联系人的电话:")

scanf("%s",fphone)

if (head==NULL)

{

printf("没有联系人!")

goto end

}

else p1=head

while(0!=strcmp(fphone,p1->name)&&p1->next!=NULL)

{

p2=p1p1=p1->next

}

p3=p1

if(0==strcmp(fphone,p1->name))

{

printf("\n姓名电话 Email职务 职称\n")

printf("%s\t%s\t\t%s\t\t%s\t\t%s\n",p3->name,p3->phone,p3->email,p3->position,p3->title)

printf("\n\t\t***************************************************")

printf("\n\t\t* Menu selection*")

printf("\n\t\t* 1.修改信息 *")

printf("\n\t\t* 2.继续查找联系人 *")

printf("\n\t\t* 3.删除当前联系人 *")

printf("\n\t\t* 4.返回主菜单 *")

printf("\n\t\t***************************************************")

printf("\n\t\t请选择您所需要的服务:")

ch=getch()

switch(ch)

{

case '1':reword(p1)

break

case '2':head=find(head)

break

case '3':

{

if(p1==head)head=p1->next

else p2->next=p1->next

printf("成功删除!")

}

break

case '4':void menu(struct list *head)

break

default:

printf("\n输入错误!")

break

}

}

else printf("没有找到!!!!")

end:

return(head)

}

/***************查找新联系人 三 email查找 *****************/

struct list *find3(struct list *head)

{

char femail[30]

struct list *p1,*p2,*p3

char ch

printf("\n请输入您要查找的联系人的Email:")

scanf("%s",femail)

if (head==NULL)

{

printf("没有联系人!")

goto end

}

else p1=head

while(0!=strcmp(femail,p1->name)&&p1->next!=NULL)

{

p2=p1p1=p1->next

}

p3=p1

if(0==strcmp(femail,p1->name))

{

printf("\n姓名电话 Email职务 职称\n")

printf("%s\t%s\t\t%s\t\t%s\t\t%s\n",p3->name,p3->phone,p3->email,p3->position,p3->title)

printf("\n\t\t***************************************************")

printf("\n\t\t* Menu selection*")

printf("\n\t\t* 1.修改信息 *")

printf("\n\t\t* 2.继续查找联系人 *")

printf("\n\t\t* 3.删除当前联系人 *")

printf("\n\t\t* 4.返回主菜单 *")

printf("\n\t\t***************************************************")

printf("\n\t\t请选择您所需要的服务:")

ch=getch()

switch(ch)

{

case '1':reword(p1)

break

case '2':head=find(head)

break

case '3':

{

if(p1==head)head=p1->next

else p2->next=p1->next

printf("成功删除!")

}

break

case '4':void menu(struct list *head)

break

default:

printf("\n输入错误!")

break

}

}

else printf("没有找到!!!!")

end:

return(head)

}

/***************查找新联系人 四 职务查找 *****************/

struct list *find4(struct list *head)

{

char fposition[30]

struct list *p1,*p2,*p3

char ch

printf("\n请输入您要查找的联系人的职务:")

scanf("%s",fposition)

if (head==NULL)

{

printf("没有联系人!")

goto end

}

else p1=head

while(0!=strcmp(fposition,p1->name)&&p1->next!=NULL)

{

p2=p1p1=p1->next

}

p3=p1

if(0==strcmp(fposition,p1->name))

{

printf("\n姓名电话 Email职务 职称\n")

printf("%s\t%s\t\t%s\t\t%s\t\t%s\n",p3->name,p3->phone,p3->email,p3->position,p3->title)

printf("\n\t\t***************************************************")

printf("\n\t\t* Menu selection*")

printf("\n\t\t* 1.修改信息 *")

printf("\n\t\t* 2.继续查找联系人 *")

printf("\n\t\t* 3.删除当前联系人 *")

printf("\n\t\t* 4.返回主菜单 *")

printf("\n\t\t***************************************************")

printf("\n\t\t请选择您所需要的服务:")

ch=getch()

switch(ch)

{

case '1':reword(p1)

break

case '2':head=find(head)

break

case '3':

{

if(p1==head)head=p1->next

else p2->next=p1->next

printf("成功删除!")

}

break

case '4':void menu(struct list *head)

break

default:

printf("\n输入错误!")

break

}

}

else printf("没有找到!!!!")

end:

return(head)

}

/***************查找新联系人 五 职称查找 *****************/

struct list *find5(struct list *head)

{

char ftitle[30]

struct list *p1,*p2,*p3

char ch

printf("\n请输入您要查找的联系人的职称:")

scanf("%s",ftitle)

if (head==NULL)

{

printf("没有联系人!")

goto end

}

else p1=head

while(0!=strcmp(ftitle,p1->name)&&p1->next!=NULL)

{

p2=p1p1=p1->next

}

p3=p1

if(0==strcmp(ftitle,p1->name))

{

printf("\n姓名电话 Email职务 职称\n")

printf("%s\t%s\t\t%s\t\t%s\t\t%s\n",p3->name,p3->phone,p3->email,p3->position,p3->title)

printf("\n\t\t***************************************************")

printf("\n\t\t* Menu selection*")

printf("\n\t\t* 1.修改信息 *")

printf("\n\t\t* 2.继续查找联系人 *")

printf("\n\t\t* 3.删除当前联系人 *")

printf("\n\t\t* 4.返回主菜单 *")

printf("\n\t\t***************************************************")

printf("\n\t\t请选择您所需要的服务:")

ch=getch()

switch(ch)

{

case '1':reword(p1)

break

case '2':head=find(head)

break

case '3':

{

if(p1==head)head=p1->next

else p2->next=p1->next

printf("成功删除!")

}

break

case '4':void menu(struct list *head)

break

default:

printf("\n输入错误!")

break

}

}

else printf("没有找到!!!!")

end:

return(head)

}

/*************** 修改联系人 *****************/

void reword(struct list *re)

{

printf("\n请依次输入修改后的姓名电话号码email职务职称信息.\n输入后以回车键进行下一项输入!\n")

scanf("%s",re->name)

scanf("%s",re->phone)

scanf("%s",re->position)

scanf("%s",re->email)

scanf("%s",re->title)

}

/*************** 排序 *****************/

struct list *sort(struct list *head,struct list *insort)

{

struct list *p1,*p2

if(NULL==head)

{

head=insort

insort->next=NULL

}

else

{

p1=p2=head

while(0>=strcmp(p1->name,insort->name)&&NULL!=p1->next)

{

p2=p1

p1=p1->next

}

if(NULL==p1->next)

{

p1->next=insort

insort->next=NULL

}

else

{

if(p2==head)head=insort

else p2->next=insort

insort->next=p1

}

}

return head

}

/*************** 主函数*****************/

void main()

{

int system(const char*)

system("color 2e")

struct list *head=NULL

menu(head)

}

1、点击【创建】-【查询设计】

2、在【显示表】中添加【工资表】

3、双击【工资表】中的【*】号(第一行)

4、双击【工资表】中的【工资】

5、在【工资】的【条件】中输入【BETWEEN 2000 AND 4000】

6、点击【运行】


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/7954308.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-11
下一篇 2023-04-11

发表评论

登录后才能评论

评论列表(0条)

保存