Home > Back-end >  Troublesome everybody PLS help have a look at, thank humbly
Troublesome everybody PLS help have a look at, thank humbly

Time:09-22

I made a small program in C language, ready to hand in your homework, but the teacher said that it requires the knowledge of the data structure, do is an ATM machine, trouble to help me change, the teacher said to use structure storage, is to add a "deposit", then the balance is a fixed value, each time a withdrawal will lose money, thanks
 

#include
#include
#include
# define clear system (" CLS ")
# define p 3800000
# define N 19
Int a, b, c, I, j, g, t;

Void gotoxy (int x, int y)/son/output positioning function
{
COORD c;
C.X=x - 1;
C.Y=y - 1;
SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), c);
}

Void delay (int) z//delay subroutine, the delay time of 1 ms
{
int m,n;
For (m=z; M> 0; M -)
For (n=110; N> 0; N -);
}

Void over ()//end module
{
clear;
Gotoxy (28, 13);
Printf (" the end of this transaction, please take card!" );
Delay (p);
}

Void progressbar ()//progress bar module
{
clear;
Gotoxy (31, 13);
Printf (" please wait ");
For (c=0; C<10; C +=2)
{
Gotoxy (38 + c, 13);
Printf (" * ");
Delay (380000);
}
}

Void the balance ()
{
clear;
Gotoxy (30, 12);
Srand (time (0));
T=rand () % 100000000;
Printf (" your balance is % d yuan!" , t);
}

Int homepage ()//home page
{
clear;
Gotoxy (30, 10);
Printf ("=========================");
Gotoxy (31, 11);
Printf (" 1 cash withdrawals 2 balance query ");
Gotoxy (31, 13);
Printf (" 3 transfer 4 exit system ");
Gotoxy (30, 14);
Printf ("=========================");
Gotoxy (30, 15);
Printf (" please enter the corresponding business options: ");
The scanf (" % d ", & amp; J);
The switch (j)
{
Case 1: getmoney (); break;
Case 2:
{
clear;
We are inquiring the printf (" ");
Progressbar ();
Gotoxy (30, 14);
The balance ();
Gotoxy (30, 14);
system("pause");
}; break;
Case 3:
{
clear;
Gotoxy (34, 13);
Printf (" business temporarily not support!" );
Delay (p);
Progressbar ();
}; break;
Case 4:
{
Progressbar ();
Over ();
Progressbar ();
The main ();
}; break;
Default: homepage (); break;
}
Homepage ();
}

Int getmoney ()
{
clear;
Gotoxy (30, 12);
Progressbar ();
clear;
Gotoxy (30, 9);
Printf ("=====================");
Gotoxy (31, 10);
Printf (" 1 100 yuan 200 yuan ");
Gotoxy (31, 12);
Printf (" 3 300 yuan 400 yuan ");
Gotoxy (31, 14);
Printf (" 5 custom 6 return ");
Gotoxy (30, 15);
Printf ("=====================");
Gotoxy (30 dec);
Printf (" please enter the corresponding options: ");
The scanf (" % d ", & amp; a);
clear;
Gotoxy (30, 13);
Progressbar ();
clear;
Gotoxy (21, 13);
The switch (a)
{
//out of his money, and don't know what to get into effect, so a word to replace!
Case 1: printf (", please check your money 100 yuan has been come out... "); break;
Case 2: printf (", please check your money 200 yuan has been come out... "); break;
Case 3: printf (", please check your money 300 yuan has been come out... "); break;
Case 4: printf (", please check your money 400 yuan has been come out... "); break;
Case 5:
{
Printf (" please enter the number you want to remove the: ");
The scanf (" % d ", & amp; B);
clear;
Gotoxy (21, 13);
Progressbar ();
clear;
If (b %==0 100 & amp; & B> 99)
{
If (b
=10000){
clear;
Gotoxy (21, 13);
Printf (" % d yuan has the bills from you, please check... ", b);
}
The else
{
clear;
Gotoxy (21, 13);
Printf (" hello, would you like to take the number of cash is too big, please go to counter!" );
}
}
The else
{
clear;
Gotoxy (15, 13);
Printf (" you input error, the input amount must be 100 integer times, please input again!" );
}
}; break;
Case 6: homepage (); break;
Default:
{
clear;
Gotoxy (35, 13);
Printf (" you input error!" );
}; break;
}
Delay (p);
Delay (p);
Getmoney ();
Getch ();
}

Int main ()//main program
{
While (1)
{
If (g<3)
{
clear;//clear screen
Gotoxy (20, 12);
Printf ("===========================================");
Gotoxy (21, 13);
Printf (" please insert your card and enter the password, after the completion of the please click confirm!" );
Gotoxy (20, 14);
Printf ("===========================================");
Gotoxy (33 (9);
Printf (" password: ");
The scanf (" % d ", & amp; I);
clear;
Gotoxy (30, 12);
Progressbar ();
The switch (I)
{
Case 123456: homepage (); break;
Default:
{
clear;
Gotoxy (30, 13);
Printf (" wrong password, please enter again!" );
clear;
Gotoxy (30, 13);
Printf (" do you have any other % d chance!" 2 - g);
+ + g;
Delay (p);
}; break;
}
}
The else
{
clear;//clear screen
Gotoxy (20, 13);
Printf (" I'm sorry, you have the wrong input three times, today was suspended use!" );
Delay (p);
Delay (p);
}
}
}
  • Related