求客户资料的C++代码,包括一般的名字,联系方式,供货地址什么的,越详细越好

[复制链接]
查看11 | 回复0 | 2009-6-24 12:45:05 | 显示全部楼层 |阅读模式
// Note:Your choice is C++ IDE#include #include "string"#include "conio.h"using namespace std;class client{ public: string name; string addr; string tel; string st;//供应什么物品 client*next;client(){next=NULL;}; void set() {cout>name;cout>st;cout>addr;cout>tel; };void show() {cout>name;while(p!=NULL){if(p->name==name) p->show(); p=p->next;} };void search_st(client*head) {string st;client *p=head;cout>st;while(p!=NULL){if(p->st==st) p->show(); p=p->next;} }; void add(client *&head,client *&p){ client *q=p; if(head!=NULL) {p=new client;p->set();q->next=p; } else{p=new client;p->set();head=p; }};void show_all(client *head){ client *p=head; coutshow();p=p->next;} }void del(client *&head){ string name; client *p=head,*q=head,*tmp; cout>name; while(p!=NULL) {if(head->name==name) {tmp=head;head=head->next;delete tmp;p=q=head;continue;}
else if(p->name==name){ q->next=p->next; tmp=p; p=p->next; delete tmp;}else {q=p;p=p->next;}} }int main(){
client *last=NULL,*head=NULL;
char i;
while(1)
{
system("cls");
cout<<
"
##
欢迎使用
##\n"<<
"-------------------------\n"<<
"
1.增加客户
\n"<<
"
2.通过客户名字查找
\n"<<
"
3.通过供应的商品查找 \n"<<
"
4.显示所有客户
\n"<<
"
5.删除某一客户
\n"<<
"
0.退出
\n"<<
"--------------------------"<<endl;
cout<<"输入数字进行操作:";
i=getch();
switch(i)
{
case '0':cout<<"****欢迎再次使用***\n"<<endl;system("pause");return 0;
case '1':add(head,last);system("pause");break;
case '2':search_name(head);system("pause");break;
case '3':search_st(head);system("pause");break;
case '4':show_all(head);system("pause");break;
case '5':del(head);system("pause");break;
default:cout<<"\n\n输入错误,请重新输入\n\n";system("pause");break;
}}
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行