C语言课程设计:电话号码存储系统,帮忙写个程序啊,,急!!!

Imhven 2011-06-11 06:16:18
我的同学给我发这个C语言的课程来给我,要我帮忙写,但是我没学过C,一点也不懂,求高手帮忙写一个完整的程序啊,谢谢了,太急了,下周一就要传给他了,麻烦帮帮忙啦!!!
C语言课程设计:电话号码存储系统
要求和实现

第一部分:需求概述
超级市场中,有的时候需要保存购买者的名称、电话号码、地址信息,以方便进行送货上门、订购服务。

电话号码目录是拥有大量数据的存储库,提供有关个人和组织的信息,简易的电话号码存储系统可以采用C语言来实现。

随着新订户的加入、一些老订户的删除以及其他订户数据的改变,必须经常地更新目录。除了添加、删除、修改操作外,还可以查询现有的数据。
第二部分:整体设计
系统采用C语言来编写,应包括下列订户详细信息:

订户名字(最多 30 个字符);
地址(最多 50 个字符);
电话号码(15位);


第三部分:5个模块,分别用函数实现
1、添加用户信息功能:可以一次完成若干条记录的输入。
2、修改用户信息功能: 按照姓名找到记录,并修改记录。
3、删除用户信息功能:按照姓名找到记录,并删除记录。
3、用户信息查询功能:完成按姓名或电话号码查找记录,并显示。
4、用户信息汇总功能:完成全部学生记录的显示。
5、排序功能:按姓名对所有记录进行排序。


注:每一次操作完成返回后都要清屏的
1、结构体类型必须定义成全局结构(函数外部定义),因为所有函数都要使用这个结构。
结构体数组建议定义成全局数组(函数外部定义),这样定义的所有功能函数就可以是无参的函数。函数调用不需要传参,共用全局数组。

#define N 500
struct tele
{char client_name[30];
char client_address[50];
char client_telephone[15];
};
struct tele telephone[N];

2、整个程序出口是当你按字符'7'退出,当你按其他字符做添加、删除等……完后都是回到主界面重新选择功能。所以整个程序是在一个循环中。

3、功能选择实现
choice=getchar();
switch(choice)
{case '1':input();break;
case '2':amend();break;
case '3':delete_client();break;
case '4':demand_client();break;
case '5':collect_client();break;
case '6':sort();break;
case '7':exit(0);
}

4、相关函数(注:每一次操作完成返回后都要清屏的)
(一)system("cls")实现清屏
system()函数的定义在#include <stdlib.h>里面

(二)exit(0);结束函数
exit(0)函数的定义在#include <stdlib.h>里面

(三)getchar()实现按任意键再继续

5、保存功能暂时我们不实现


...全文
364 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Imhven 2011-06-11
  • 打赏
  • 举报
回复
我要的是用C写的,C++写一点问题都没[Quote=引用 1 楼 namelij 的回复:]

楼主,我就不帮你写代码了
下面链接里面的能满足你的要求
楼主加油
http://download.csdn.net/source/880217
[/Quote]
蓝染忽右介 2011-06-11
  • 打赏
  • 举报
回复
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 500
struct tele
{
char client_name[30];
char client_address[50];
char client_telephone[15];
};
struct tele telephone[N];
int cur=0;
void input(struct tele *s);
int amend(struct tele *s);
int delete_client(struct tele *s);
int demand_client(struct tele *s);
void collect_client(struct tele *s);
void sort(struct tele *s);
int main()
{
char choice;
do
{

system("cls");
printf("**************************\n");
printf("1:添加用户信息\t\t**\n2:修改用户信息\t\t**\n3:删除用户信息\t\t**\n4:用户信息查询\t\t**\n5:用户信息汇总\t\t**\n6:排序\t\t\t**\n7:退出\t\t\t**\n");
printf("**************************\n:");

fflush(stdin);
choice=getchar();
switch(choice)
{
case '1':input(telephone);break;
case '2':amend(telephone);break;
case '3':delete_client(telephone);break;
case '4':demand_client(telephone);break;
case '5':collect_client(telephone);break;
case '6':sort(telephone);break;
case '7':exit(0);
}
getch();

}while(1);

return 0;
}


void input(struct tele *s)
{
if(cur==N-1)
{
printf("容量已满无法存储");
return;
}
else
{
printf("请输入订户的名字、地址和电话号码:");
fflush(stdin);
scanf("%s%s%s",s[cur].client_name,s[cur].client_address,s[cur].client_telephone);
cur++;

}
return ;
}
int amend(struct tele *s)
{
int i=0;
char str[30];
printf("请输入需要修改订户的姓名:");
fflush(stdin);
gets(str);
while(strcmp(s[i].client_name,str)!=0&&i<=cur)
i++;
if(i>cur)
{
printf("订户不存在");
return 0;
}
printf("订户的名字 地址 电话号码\n");
printf("%s %s %s\n",s[i].client_name,s[i].client_address,s[i].client_telephone);
printf("请重新输入订户的名字、地址和电话号码:");
fflush(stdin);
scanf("%%s%s%s",s[i].client_name,s[i].client_address,s[i].client_telephone);
return 1;
}
int delete_client(struct tele *s)
{
int j,i=0;
char str[30];
printf("请输入要删除订户的姓名:");
fflush(stdin);
gets(str);
while(strcmp(s[i].client_name,str)!=0&&i<=cur)
i++;
if(i>cur)
{
printf("订户不存在,无法删除");
return 0;
}
for(j=i+1;j<=cur;j++)
s[j-1]=s[j];
cur--;
return 1;
}

int demand_client(struct tele *s)
{
int men,i=0;
char str[30];
printf("**1:按姓名查找输\n**2:按电话号码查找\n:");
fflush(stdin);
scanf("%d",&men);
switch(men)
{
case 1:
printf("请输入订户姓名:");
fflush(stdin);
scanf("%s",str);
while(strcmp(s[i].client_name,str)!=0&&i<=cur)
i++;
if(i>cur)
{
printf("订户不存在");
return 0;
}
printf("订户的名字\t地址\t电话号码\n");
printf("%s %s %s\n",s[i].client_name,s[i].client_address,s[i].client_telephone);
break;
case 2:
printf("请输入订户电话号码:");
fflush(stdin);
scanf("%s",str);
while(strcmp(s[i].client_telephone,str)!=0&&i<=cur)
i++;
if(i>cur)
{
printf("订户不存在");
return 0;
}
printf("订户的名字\t地址\t电话号码\n");
printf("%s %s %s\n",s[i].client_name,s[i].client_address,s[i].client_telephone);
break;
default:break;
}
return 1;
}
void collect_client(struct tele *s)
{
int i;
printf("订户的名字\t地址\t电话号码\n");
for(i=0;i<=cur;i++)
{
printf("%s %s %s\n",s[i].client_name,s[i].client_address,s[i].client_telephone);
}
}
void sort(struct tele *s)
{
struct tele a;
int i,j;
for(i=0;i<cur;i++)
for(j=i+1;j<=cur;j++)
if(strcmp(s[i].client_name,s[j].client_name)>0)
{
a=s[i];
s[i]=s[j];
s[j]=a;
}
}
Imhven 2011-06-11
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 namelij 的回复:]

楼主,我就不帮你写代码了
下面链接里面的能满足你的要求
楼主加油
http://download.csdn.net/source/880217
[/Quote]霜狼
Imhven 2011-06-11
  • 打赏
  • 举报
回复
我要的是用C写的,C++写一点问题都没
  • 打赏
  • 举报
回复
楼主,我就不帮你写代码了
下面链接里面的能满足你的要求
楼主加油
http://download.csdn.net/source/880217

69,368

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧