#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Link *Kaihu(struct Link *head);
struct Link *Xiaohu(struct Link *head);
Chakan(struct Link *head);
Cunkuan (struct Link *head);
Qukuan(struct Link *head);
struct Link
{
int id;
char name[10];
int num;
struct Link *next;
};
main()
{
int i;
char c;
struct Link *head=NULL;
printf("SHI FOU XU YAO BAN LI YE WU(y/n)");
scanf("%c",&c);
while(c=='y')
{ printf("****************************************************************/n");
printf(" Main Menu/n");
printf(" 1 Kaihu/n");
printf(" 2 Xiaohu/n");
printf(" 3 Cunkuan/n");
printf(" 4 Qukuan/n");
printf(" 5 Chakan/n");
printf("****************************************************************/n");
printf("Please select the needful operation:/n ");
scanf(" %d",&i);
switch(i)
{
case 1:
head=Kaihu(head);
break;
case 2:
head=Xiaohu(head);
break;
case 3:
Cunkuan(head);
break;
case 4:
Qukuan(head);
break;
case 5:
Chakan(head);
break;
default:
printf("MING LING FEI FA");
printf("/n");
}
printf("SHI FOU XU YAO BAN LI QI TA YE WU(y/n)/n");
scanf(" %c",&c);
}
}
struct Link *Kaihu(struct Link *head)
{
struct Link *p=NULL;
struct Link *pr=head;
int id ;
char name[10];
int num;
p=(struct Link *)malloc(sizeof(struct Link));
if(p==NULL)
{
printf(" error");
exit(0);
}
if(head==NULL)
{
head=p;
}
else
{
while(pr->next!=NULL)
{
pr=pr->next;
}
pr->next=p;
}
pr=p;
printf("Please input the depositor's name:/n");
scanf("%s",pr->name);
printf(" Please input the depositor's id:/n");
scanf("%d",&id);
pr->id=id;
printf("Please input the money:/n");
scanf("%d",&num);
pr->num=num;
pr->next=NULL;
return head;
}
struct Link *Xiaohu(struct Link *head)
{
int j;
struct Link *p=head,*pr=head;
printf("Please input acount id:/n");
scanf("%d",&j);
if(head==NULL)
{
printf("error");
}
while(j!=p->id&&p->next!=NULL)
{
pr=p;
p=p->next;
}
if(j==p->id)
{
if(p==head)
{
head=p->next;
}
else
{
pr->next=p->next;
}
free(p);
}
else
{
printf("WU CI ZHANG HU/n");
}
return head;
}
Qukuan(struct Link *head)
{
int m,n;
struct Link *p=head;
if(head==NULL)
{
printf("error");
}
printf("Please input depositor's id:");
scanf("%d",&m);
printf("Please input depositor's money:");
scanf("%d",&n);
while(m!=p->id&&p->next!=NULL)
{
p=p->next;
}
if(m==p->id)
{
if(p->num<n)
{
printf("***The balance money is not enough***:");
}
else
{
p->num=p->num-n;
}
}
else
printf("***Wu ci yong hu!!!!!!!***/n");
}
Cunkuan (struct Link *head)
{
int m,n;
char name[10];
struct Link *p=head;
printf("Please input depositor's id:");
scanf("%d",&m);
printf("Please input the access money/n");
scanf("%d",&n);
while(m!=p->id&&p->next!=NULL)
{
p=p->next;
}
if(m==p->id)
{
p->num=p->num+n;
}
else
printf("***Wu ci yong hu!!!!!!***/n");
}
Chakan(struct Link *head)
{ int m;
struct Link *p=head;
printf("Please input the id:");
scanf("%d",&m);
while(m!=p->id&&p!=NULL)
{
p=p->next;
}
if(p==NULL)
printf("***Wu xi yong hu!!!!!!***/n");
else
{
printf("depositor: %d/n",p->id);
printf("depositor name: %s/n",p->name);
printf("balance money: %d/n",p->num);
}
}