Home > Back-end >  How to give a simple c program to add background
How to give a simple c program to add background

Time:09-25

Beginner c, the following is a summary of pharmacy system
How to let his background is not black color, add background











# include
# include
# include
# include
Struct medicine
{
char name[20];
Char number [50].
Char price [50];
Char inventory [50].
Char brand [20].
} medicine [100].

int num;
Int menu_select ()
{
Char s [80];
int a;
System (" CLS ");
Printf (" \ t \ t -- -- -- -- -- -- -- -- -- -- -- -- -- hello! You have entered the pharmacy management system -- -- -- -- -- -- -- -- -- -- - \ n \ n ");
Printf (" \ t \ \ t t1. Input drug information \ n ");
Printf (" \ t \ \ t t2. See the drug information \ n ");
Printf (" \ t \ \ t t3. Modify the drug information \ n ");
Printf (" \ t \ \ t t4. According to the serial number to find drugs \ n ");
Printf (" \ t \ \ t t5. Sort by price \ n ");
Printf (" \ t \ \ t t6. Delete the drug information \ n ");
Printf (" \ t \ t \ t7 has quit \ n ");
Printf (" \ t \ t -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n \ n ");
Do {
Printf (" Enter you choice (1 ~ 7) : ");
scanf("%s",s);
A=atoi (s);
}
While (a<1 | | a> 7);
return a;
}
Int addmedicine ()
{
Printf (" \ t \ \ t t -- -- -- -- -- -- -- -- -- -- -- -- -- -- please enter information you want to save -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
Printf (" \ t \ \ t t type drug name: \ n ");
The scanf (" % s ", medicine [num] name);
Printf (" \ t \ \ t t input drug number: \ n ");
The scanf (" % s ", medicine [num] number);
Printf (" \ t \ \ t t unit price: \ n ");
The scanf (" % s ", medicine [num] price);
Printf (" \ t \ \ t t brand: \ n ");
The scanf (" % s ", medicine [num] brand);
Printf (" \ t \ \ t t inventory quantity: \ n ");
The scanf (" % s ", medicine [num] inventory);
num++;
Printf (" \ t \ \ t t continue to add? (Y/N) : \ N ");
If (getch ()=='y' | | getch ()=='y')
Addmedicine ();
Return (0);
}
Void modifybyname ()
{
char c;
Int I, mark=0;
char name[20];
Printf (" \ n \ t \ t please type in the name of the drug to be modified: ");
The scanf (" % s ", name);
If (num==0)
{
Printf (" \ n \ t \ t file no related drugs ");
Printf (" \ n \ t \ t press any key to return to the main menu ");
getch(); Mark++;
return;
}
for(i=0; i{
If (STRCMP (medicine [I]. Name, name)==0)
{
Printf (" \ n \ t \ t here's what you want to modify drug information ");
Printf (" \ n \ t \ t drug name: % s ", medicine [I] name);
Printf (" \ n \ t \ t drug number: % s ", medicine [I] number);
Printf (" \ n \ t \ t unit price: % s ", medicine [I] price);
Printf (" \ n \ t \ t brand: % s ", medicine [I] brand);
Printf (" \ n \ t \ t inventory quantity: % s ", medicine [I] the inventory).
Printf (" \ n \ t \ t whether changes (y/n) ");
If (getch ()=='y')
{
Printf (" \ n \ t -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - please choose to modify the information -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ");
Printf (" \ n \ t 1 - modified drug name ");
Printf (" \ n \ t 2 - modified drug code ");
Printf (" \ n \ t 3 - modify the unit price ");
Printf (" \ n \ t 4 to modify the brand ");
Printf (" \ n \ t 5 - modified inventory quantity ");
Printf (" \ n \ t -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ");
Printf (" \ n \ t, please select the service you have to: ");
The scanf (" % s ", & amp; C);
The switch (c)
{
Case '1' : printf (" \ n \ t name: please enter the new drug ");
The scanf (" % s ", medicine [I] name); break;
Case '2' : printf (" \ n \ t please enter the number of new drugs: % s ");
The scanf (" % s ", medicine [I] number); break;
Case '3' : printf (" \ n \ t please enter the new unit price: ");
The scanf (" % s ", medicine [I] price); break;
Case '4' : printf (" \ n \ t please enter new brand: ");
The scanf (" % s ", medicine [I] brand); break;
Case '5' : printf (" \ n \ t please enter the number of new inventory: ");
The scanf (" % s ", medicine [I] the inventory). break;
}
}
}
}
If (mark==0)
{
Printf (" \ n \ t \ t modified drug information ");
Printf (" \ n \ t continue to modify? (Y/N) : ");
If (getch ()=='y')
Modifybyname ();
return;
}
}
Void list ()
{
int i;
System (" CLS ");
If (num!=0)
{
Printf (" \ t \ \ t t -- -- -- -- -- -- -- -- -- -- have you show all drugs for information -- -- -- -- -- -- -- -- -- -- \ n ");
for (i=0; i{
Printf (" \ t \ \ t t drug name: % s \ n ", medicine [I] name);
Printf (" \ t \ \ t t drug number: % s \ n ", medicine [I] number);
Printf (" \ t \ \ t t unit price: % s \ n ", medicine [I] price);
Printf (" \ n \ t \ t brand: % s \ n ", medicine [I] brand);
Printf (" \ t \ \ t t inventory quantity: % s \ n ", medicine [I] the inventory).
If (I + 1 & lt; Num)
{
System (" pause ");
}
}
Printf (" \ t \ \ t t -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
}
The else
Printf (" \ t \ \ t t no any record in system \ n ");
Printf (" \ t \ \ t t press any key to return to the main menu: \ n ");
getch();
return;
}
Int searchbyname ()
{
Int mark=0;
int i;
Printf (" \ t \ \ t t -- -- -- -- -- -- -- -- -- -- according to the drug name lookup -- -- -- -- -- -- -- -- -- -- \ n ");
char name[20];
Printf (" please enter the name of the drug \ t \ \ t t: \ n ");
The scanf (" % s ", name);
for(i=0; i{
If (STRCMP (medicine [I]. Name, name)==0)
{
Printf (" \ t \ \ t t -- -- -- -- -- -- -- here's what you find drug information -- -- -- -- -- -- -- \ n ");
Printf (" \ t \ \ t t drug name: % s ", medicine [I] name);
Printf (" \ t \ \ t t drug number: % s ", medicine [I] number);
Printf (" \ t \ \ t t unit price: % s ", medicine [I] price);
Printf (" \ n \ t \ t brand: % s ", medicine [I] brand);
Printf (" \ t \ \ t t inventory quantity: % s \ n ", medicine [I] the inventory).
Printf (" \ t \ \ t t -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
Mark++;
If ((I + 1) & lt; Num)
{
Printf (" \ t \ \ t t whether to continue to find the same name of drug information: (y/n) \ n ");
If (getch ()=='y' | | getch ()=='y')
{
continue;
}
The else
Return (0);
}
The else
{
Printf (" \ t \ \ t t please press any key to return to the main menu ");
getch();
Return (0);
}
}
}
If (mark==0)
{
Printf (" \ t t \ \ t have you to find drugs record \ n ");
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related