A simple banking system implemented in C language, including teller number: hou520 and login password: 13145

From , 3 Years ago, written in C++, viewed 186 times.
URL https://pastebin.vip/view/798cebcc
  1. #include "stdio.h"
  2. #include "stdlib.h"
  3. #include "string.h"
  4. #include "time.h"
  5. int menu();
  6. int open();//开户
  7. int save();//存钱
  8. int take();//取钱
  9. int check();//查询
  10. int exchange();//转账
  11. int getacc(int acc,float money);//接收转账
  12. int login();//登录
  13. int print(int count);//打印
  14. int randopen();//生成随机账号
  15. int root()
  16. {
  17.         int i,j;
  18.         printf("\n\n\n\n\n\n");
  19.         printf("                                正在登陆\n");
  20.         for(i=0;i<80;i++)
  21.         {
  22.                 printf("=");
  23.         }
  24.         for(i=0;i<80;i++)
  25.         {
  26.                 printf(">");
  27.                 for(j=0;j<9000000;j++);
  28.         }
  29.         return 0;
  30. }
  31. int first()
  32. {
  33.         int i,j;
  34.         char username[5];
  35.     char password[10];
  36.     printf("\n\n\n\n\n\n\n              请输入柜员用户名:");
  37.     scanf("%s",&username);
  38.     printf("            请输入登录密码:");
  39.     scanf("%s",&password);
  40.     if(strcmp(username,"hou520")==0&&strcmp(password,"1314520")==0)
  41.     {
  42.         printf("                        登录成功");
  43.         for(i=0;i<3;i++)
  44.         {
  45.                 printf(".");
  46.                 for(j=0;j<90000000;j++);
  47.         }
  48.     }
  49.     else
  50.     {
  51.         printf("                帐号或密码错误!\n");
  52.     }
  53.     return 0;
  54. }
  55. struct
  56. {
  57.         char username[20];
  58.         char password[20];
  59.         int accont;
  60.         float money;
  61. }person[1000];
  62. int count=0;
  63.  
  64. int main()
  65. {
  66.         system("color 9e");
  67.         first();
  68.         system("cls");
  69.         root();
  70.         system("cls");
  71.         system("color 9e");
  72.     menu();
  73.     return 0;
  74. }
  75. int menu()
  76. {
  77.         int a;
  78.        
  79.         do
  80.         {
  81.         printf("                ***********************************************\n");
  82.         printf("                *                                             *\n");
  83.         printf("                *       Welcome to the BANK OF YOUMING!       *\n");
  84.         printf("                *                                             *\n");
  85.         printf("                ***********************************************\n");
  86.         printf("                1、开户\n            2、存款\n            3、取款\n            4、查询\n            5、转账\n            6、退出\n");
  87.         printf("                请选择以下操作:");
  88.         scanf("%d",&a);
  89.         system("cls");
  90.         switch(a)
  91.         {
  92.                 case 1:open();break;
  93.                 case 2:save();break;
  94.                 case 3:take();break;
  95.                 case 4:check();break;
  96.                 case 5:exchange();break;
  97.                 case 6:break;
  98.                 default:printf("                请选择1-6之间的有效选择\n");
  99.         }
  100.         }while(a!=6);
  101.         return 0;
  102. }
  103. int randopen()
  104. {
  105.         int i;
  106.         int open;
  107.         srand(time(0));
  108.         open=rand();
  109.         for(i=0;i<count;i++)
  110.         {
  111.                 if(open==person[i].accont)
  112.                 {
  113.                         open<<=2;
  114.                 }
  115.         }
  116.         return open;
  117. }
  118. int print(int count)
  119. {
  120.         printf("                你的账号是:%d\n",person[count].accont);
  121.         printf("                你的用户名是:%s\n",person[count].username);
  122.         printf("                你账户的余额:%.2f\n",person[count].money);
  123.         return 0;
  124. }
  125. int open()
  126. {
  127.         char password[20];
  128.         printf("                请输入注册用户名:");
  129.         scanf("%s",&person[count].username);
  130.         printf("                请输入用户密码:");
  131.         scanf("%s",&password);
  132.         printf("                请确认用户密码:");
  133.         scanf("%s",&person[count].password);
  134.         if(strcmp(password,person[count].password)==0)
  135.         {
  136.                 printf("                *******************开户成功!*******************\n           账户信息如下:\n");
  137.                 person[count].accont=randopen();
  138.                 person[count].money=0.f;
  139.                 print(count);
  140.                 printf("                你的账户密码是:%s,请牢记!\n",password);
  141.                 count++;
  142.         }
  143.         else
  144.         {
  145.                 printf("                *************密码不一致,开户失败!*************\n");
  146.         }
  147.         return 0;
  148. }
  149. int login()
  150. {
  151.         int accont,i;
  152.         char password[20];
  153.         printf("                请输入你的账号:");
  154.         scanf("%d",&accont);
  155.         printf("                请输入账户密码:");
  156.         scanf("%s",&password);
  157.         for(i=0;i<count;i++)
  158.         {
  159.                 if(accont==person[i].accont)
  160.                 {
  161.                         return i;
  162.                 }
  163.         }
  164.         printf("                你输入的账号或密码有误!\n");
  165.         return -1;
  166. }
  167. int save()
  168. {
  169.         float money;
  170.         int count=login();
  171.         if(count!=-1)
  172.         {
  173.                 printf("                请输入你的存款数额:");
  174.                 scanf("%f",&money);
  175.                 if(money>=0)
  176.                 {
  177.                 person[count].money+=money;
  178.                 printf("                你存了%d元!\n",money);
  179.                 print(count);
  180.                 }
  181.                 else
  182.                 {
  183.                         printf("                你的输入有误,请重新输入!\n");
  184.                 }
  185.         }
  186.         return 0;
  187. }
  188. int take()
  189. {
  190.         float money;
  191.         int count=login();
  192.         if(count!=-1)
  193.         {
  194.                 printf("                请输入你的取款数额:");
  195.                 scanf("%f",&money);
  196.                 if(money>=0&&money<=person[count].money)
  197.                 {
  198.                 person[count].money-=money;
  199.                 printf("                你取了%d元!\n",money);
  200.                 print(count);
  201.                 }
  202.                 else
  203.                 {
  204.                         printf("                你的输入有误,请重新输入!\n");
  205.                 }
  206.         }
  207.         return 0;
  208. }
  209. int check()
  210. {
  211.         int count=login();
  212.         if(count!=-1)
  213.         {
  214.                 print(count);
  215.         }
  216.         return 0;
  217. }
  218. int exchange()
  219. {
  220.         int acc_1,acc_2;
  221.         float money;
  222.         int count=login();
  223.         if(count!=-1)
  224.         {
  225.         printf("                请输入转账账号:");
  226.         scanf("%d",&acc_1);
  227.         printf("                请确认对方账号:");
  228.         scanf("%d",&acc_2);
  229.         if(acc_1==acc_2)
  230.         {
  231.                 printf("                请输入你要转入的金额:");
  232.                 scanf("%f",&money);
  233.                 if(money>=0&&money<=person[count].money)
  234.                 {
  235.                 int accCount=getacc(acc_1, money);
  236.                 if(accCount != -1)
  237.                 {
  238.                         printf("                转账成功!\n");
  239.                         person[count].money-=money;
  240.                         printf("                你向对方了%d元!\n",money);
  241.                 }
  242.                 print(count);
  243.                 }
  244.         }
  245.         else
  246.         {
  247.                 printf("                你的操作有误!\n");
  248.         }
  249.         }
  250.         return 0;
  251. }
  252. int getacc(int acc,float money)
  253. {
  254.         int i;
  255.         for(i=0;i<count;i++)
  256.         {
  257.                 if(person[i].accont==acc)
  258.                 {
  259.                         person[i].money+=money;
  260.                         return i;
  261.                 }
  262.         }
  263.         printf("                账号不存在!\n");
  264.         return -1;
  265. }

Reply to "A simple banking system implemented in C language, including teller number: hou520 and login password: 13145"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website