⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atm.txt

📁 任务是开发一个模拟的ATM系统
💻 TXT
📖 第 1 页 / 共 2 页
字号:
        p=p->next;                                     /*文件的正确存入-代码*/
      } while(p!=NULL);                               /*文件的正确存入-代码*/     
      /*print(head);    调试用*/ 
      fclose(fp);/*关闭文件*/
     clrscr();   /*清屏*/
     gotoxy(Y+8,Z);printf("Added user");   /*将该子函数的最后的输出到指定位置*/
     out: return(head);
   } 
   struct yonghu *shanchu(struct yonghu *head)          /*删除用户*/
   {FILE *fp;
   	struct yonghu *p1,*p2,*p;
   	long zhanghao;
     loop1:gotoxy(Y,Z);printf("Please enter the user's name you want to cancel\n");
           gotoxy(Y+8,Z+3);scanf("%ld",&zhanghao);
           p1=head;
    while(p1->zhang!=zhanghao && p1->next!=NULL)
       { p2=p1;
         p1=p1->next;
       }
    if(zhanghao==p1->zhang)
      {if(p1==head)  head=p1->next;
       else  p2->next=p1->next;
        if((fp=fopen("d:\\sj.txt","w"))==NULL)     /*文件的正确存入-代码*/
         { clrscr();  /*清屏*/
           gotoxy(X+8,Y+6);                         /*将显示的字符移动到屏幕中间*/
           printf("cannot open file \n");        /*文件的正确存入-代码*/
           getch();
           goto out;                    /*如不能打开文件,则退出该子程序*/
         }             
     p=head;                                     /*文件的正确存入-代码*/
       do                         /*文件的正确存入-代码*/
      {/* printf("%ld,%c,%c,%c,%c,%c,%c,%ld,%d,\n",p->zhang,p->mi[0],p->mi[1],p->mi[2],p->mi[3],p->mi[4],p->mi[5],p->yu,p->lei);  文件的正确存入-代码*/
        fprintf(fp,"%ld,%c,%c,%c,%c,%c,%c,%ld,%d,",p->zhang,p->mi[0],p->mi[1],p->mi[2],p->mi[3],p->mi[4],p->mi[5],p->yu,p->lei);  /*文件的正确存入-代码*/
        p=p->next;                                     /*文件的正确存入-代码*/
      } while(p!=NULL);/*文件的正确存入-代码*/
      fclose(fp);/*关闭文件*/
        clrscr();  /*清屏*/ 
       gotoxy(Y+8,Z+6);printf("Canceled user%ld\n",zhanghao);   /*将该子函数的最后的输出到指定位置*/
       /*print(head);调试用*/ 
      }
    else { clrscr();  /*清屏*/
    	   gotoxy(X+8,Y+6);
    	   printf("The user you want to cancel does not exist\n");
    	   getch();
    	   clrscr();  /*清屏*/
           goto loop1;
         }
    out:return(head);
   }
 struct yonghu *xiugai(struct yonghu *head)   /*修改用户信息*/
   { FILE *fp;
   	 struct yonghu *p1,*p;
     long a;
     int b;
     loop1:gotoxy(Y,Z);printf("Please enter the user's name you want to modify\n");
           gotoxy(Y+8,Z+3);scanf("%ld",&a);
           p1=head;
           while(p1->zhang!=a&&p1->next!=NULL)
              p1=p1->next;
           if(p1->zhang!=a) { clrscr();  /*清屏*/
    	                      gotoxy(X+8,Y+4);printf("The user you want to modify does not exist ");
           	                  gotoxy(X+8,Y+6);printf("Plaese input again");
           	                  getch();
           	                  clrscr();  /*清屏*/
                              goto loop1;
                            }  /*检查最后一个结点是否是要查询的*/     
     loop2:gotoxy(Y,Z);printf("Please enter the user's new name\n");
           gotoxy(Y+8,Z+2);scanf("%ld",&p1->zhang);
           shumi(p1);
           gotoxy(Y,Z+8);printf("please input the new user's balance\n");
           gotoxy(Y+8,Z+10);scanf("%ld",&p1->yu);
           gotoxy(Y,Z+12);printf("please input the new user's type\n");
           gotoxy(Y+8,Z+14);scanf("%d",&p1->lei);
           clrscr();  /*清屏*/
           gotoxy(Y,Z);printf("The information you input are:");
           gotoxy(Y+6,Z+2);printf("Name: %ld",p1->zhang);
           gotoxy(Y+6,Z+4);printf("Password:%c%c%c%c%c%c",p->mi[0],p->mi[1],p->mi[2],p->mi[3],p->mi[4],p->mi[5]);
           gotoxy(Y+6,Z+6);printf("Balance:%ld",p1->yu);
           gotoxy(Y+6,Z+8);printf("Type:%d",p1->lei);
		   gotoxy(Y-6,Z+10);printf("Are you sure the information is you want to enter");
		   gotoxy(Y,Z+12);printf("sure(press 1)     cancel(press 2)\n");
           scanf("%d",&b);
           clrscr();  /*清屏*/
           if(b==2) goto loop2;
           else { if((fp=fopen("d:\\sj.txt","w"))==NULL)     /*文件的正确存入-代码*/
                    { clrscr();  /*清屏*/
                      gotoxy(X+8,Y+6);                         /*将显示的字符移动到屏幕中间*/
                      printf("cannot open file \n");              /*文件的正确存入-代码*/
                      getch();
                      goto out;      /*如不能打开文件,则退出该子程序*/
                    }
                    p=head;                                     /*文件的正确存入-代码*/
                    do                         /*文件的正确存入-代码*/
                     {  /*printf("%ld,%c,%c,%c,%c,%c,%c,%ld,%d,\n",p->zhang,p->mi[0],p->mi[1],p->mi[2],p->mi[3],p->mi[4],p->mi[5],p->yu,p->lei); 文件的正确存入-代码*/
                       fprintf(fp,"%ld,%c,%c,%c,%c,%c,%c,%ld,%d,",p->zhang,p->mi[0],p->mi[1],p->mi[2],p->mi[3],p->mi[4],p->mi[5],p->yu,p->lei);  /*文件的正确存入-代码*/
                       p=p->next;                                     /*文件的正确存入-代码*/
                     } while(p!=NULL);                               /*文件的正确存入-代码*/
                     fclose(fp);/*关闭文件*/
                }
           clrscr();   /*清屏*/      
     gotoxy(Y+8,Z+6);printf("Modified information");     /*将该子函数的最后的输出到指定位置*/
     /*print(head);调试用*/
     out:return(head);
   }
 void chaxun(struct yonghu *head)      /*管理员查询*/
    { struct yonghu *p1;
      long a;
       loop1:gotoxy(Y,Z);printf("Please enter the user's name you want to inquire");
             gotoxy(Y+8,Z+3);scanf("%ld",&a);
             p1=head;
             while(p1->zhang!=a&&p1->next!=NULL)
                p1=p1->next;
             if(p1->zhang!=a) { clrscr();  /*清屏*/
                                gotoxy(X+8,Y+6);                         /*将显示的字符移动到屏幕中间*/
             	                printf("The user does not exist,Plaese input again");
             	                getch();
             	                clrscr();  /*清屏*/
                                goto loop1;
                              }  /*检查最后一个结点是否是要查询的*/
      clrscr();  /*清屏*/       
      gotoxy(Y,Z);printf("The user's information are"); 
      gotoxy(Y+6,Z+2);printf("account:%ld ",p1->zhang);
      gotoxy(Y+6,Z+4);printf("password:%c%c%c%c%c%c ",p1->mi[0],p1->mi[1],p1->mi[2],p1->mi[3],p1->mi[4],p1->mi[5]);
      gotoxy(Y+6,Z+6);printf("balance:%ld yuan ",p1->yu);
      gotoxy(Y+6,Z+8);printf("type:%d",p1->lei);
      getch();
      clrscr();  /*清屏*/
    }
  void main()
   { int A,B,C,r;
   	 long zh;
     struct yonghu *head,*p1;
     head=creat();
     print(head);
    textbackground(1);
    textcolor(10);
    clrscr();         
loop: gotoxy(Y,Z);   printf("   Welcome to use the ATM system!");
      gotoxy(Y,Z+5);printf("press 1  Enter the user interface          ");
      gotoxy(Y,Z+10);printf("press 2  Enter the administrator interface ");
      gotoxy(Y,Z+15);printf("   Press the other key to Exit\n                        ");  
     /*A=getch();*/scanf("%d",&A); 
     clrscr(); /* 清屏 */
     if(A==1){ /*p1=denglu(head,1); */
     	loop1: gotoxy(Y,Z);printf("Please iuput your user's name\n");
               gotoxy(Y+8,Z+3);scanf("%ld",&zh);
               p1=head;
               while(p1->zhang!=zh&&p1->next!=NULL)
                     p1=p1->next;
               if(p1->zhang!=zh) { gotoxy(Y,Z+5);printf("user does not exist,Please enter again\n");
            	                   getch();
            	                   clrscr();
                                   goto loop1;
                                 }
                 r=denglu(p1,1);
     	        if(r>=3)  goto loop;  /*如果输入三次密码都错误,则跳到起始界面*/
     	        if(p1->lei!=1) goto loop;  /*如果类型不匹配,跳到起始界面*/
     	       /* clrscr();  清屏 */
     	        do
              { gotoxy(Y,Z);printf("Please press key to choose");
              	gotoxy(Y,Z+3);printf("1.modify password ");
              	gotoxy(Y,Z+6);printf("2.require balance");
              	gotoxy(Y,Z+9);printf("3.store money ");
              	gotoxy(Y,Z+12);printf("4.take money   ");
              	gotoxy(Y,Z+15);printf("5.exit   ");
                /*B=getch(); */scanf("%d",&B);
                clrscr();    /* 清屏 */
                switch(B)    
                   { case 1: gaimi(head,p1);break;  /*存入文件已调好*/        
                     case 2: chayu(p1);break;   /*存入文件已调好*/   
                     case 3: cun(head,p1);break;    /*存入文件已调好*/
                     case 4: qu(head,p1);break;     /*存入文件已调好*/
                     default:goto loop; 
                   }
                gotoxy(Y,Z+3);printf("Do  you  want  to  continue?");
                gotoxy(Y,Z+6);printf(" Yes           (Press 1)");
                gotoxy(Y,Z+9);printf(" No (Press 2 or other key)\n                   ");        
                /*C=getch();*/scanf("%d",&C);
                clrscr();  /*清屏 */
              }while(C==1);
                gotoxy(Y+8,Z+6);printf("Thinks!\n");/*将显示的字符移动到屏幕中间*/
                getch();
                clrscr(); /* 清屏 */             
                goto loop; 
              }
     else if(A==2) { loop2: gotoxy(Y,Z);printf("Please iuput your user's name\n");
                            gotoxy(Y+8,Z+3);scanf("%ld",&zh);
                            p1=head;
                            while(p1->zhang!=zh&&p1->next!=NULL)
                               p1=p1->next;
                            if(p1->zhang!=zh) { gotoxy(Y,Z+5);printf("user does not exist,Please enter again\n");
            	                                getch();
            	                                clrscr();
                                                goto loop2;
                                              }
     	             r=denglu(p1,2);
     	             if(r>=3)  goto loop;  /*如果输入三次密码都错误,则跳到起始界面*/
     	             if(p1->lei!=2) goto loop; /*如果类型不匹配,跳到起始界面*/
     	            /*clrscr(); 清屏 */
     	           do
                    { gotoxy(Y,Z);printf("Please press key to choose");
          	          gotoxy(Y,Z+3);printf("1.Add user  ");
          	          gotoxy(Y,Z+6);printf("2.Cancel user  ");
          	          gotoxy(Y,Z+9);printf("3.Modify user's information ");
          	          gotoxy(Y,Z+12);printf("4.Inquire");
          	          gotoxy(Y,Z+15);printf("5.exit    ");
            /*B=getch(); */scanf("%d",&B); 
                      clrscr(); /* 清屏 */
                       switch(B)
                         { case 1:tianjia(head);break;   /*存入文件已调好*/
                           case 2:shanchu(head);break;   /*存入文件已调好*/
                           case 3:xiugai(head);break;    /*存入文件已调好*/
                           case 4:chaxun(head);break;    /*存入文件已调好*/
                           default:goto loop;
                         } 
                      gotoxy(Y,Z+3);printf("Do  you  want  to  continue?");
                      gotoxy(Y,Z+6);printf(" Yes           (Press 1)");
                      gotoxy(Y,Z+9);printf(" No (Press 2 or other key)  ");
            /*C=getch(); */scanf("%d",&C);
                      clrscr();  /* 清屏 */
                   }while(C==1);
                    gotoxy(Y+8,Z+6);printf("Thinks!\n"); /*将显示的字符移动到屏幕中间*/
                    getch();
                    clrscr();  /* 清屏 */
                    goto loop; 
                   }
       else gotoxy(Y+10,Z+6);      /*将显示的字符移动到屏幕中间*/
            printf("Good Bye!\n"); 
       } 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -