活期账户储蓄课程设计

#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);

      }

}

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值