order
Some people will never be together in this life, but there is a feeling that can be hidden in their heart and kept for a lifetime.
Hi, this is fox~~
I haven't seen you for a few days. I went out the day before yesterday. I rested for a day and began to work hard today. Time really flies. 2021 will pass in the twinkling of an eye. I don't know whether everyone's wishes this year have been realized. Some people are happy, some are sad, and some are sad because the semester is coming to an end, But haven't you done your own lesson design yet? Hey, there must be. Today we will continue to share the lesson design homework. I don't know if you have mastered the last student performance management system. I hope you can successfully complete your lesson design homework. Today we share the "address book management system". I hope you can read it patiently and carefully and start to realize it.
1, Demand analysis
demand
1. A telephone book management program with the functions of data insertion, modification, deletion, display and query.
2. The data includes: person name, work unit, telephone number and E-MAIL address.
3. The names and phone numbers in the record can be modified.
4. Records can be added and deleted.
5. All saved records can be displayed.
6. You can query by person's name or telephone number.
analysis
Structure array and file system are recommended. Structure members include person name, work unit, telephone number and E-MAIL address. According to the requirements of the topic, the program should be implemented by structure array and file system. There should be file operation function; The program shall include the functions of input, display, deletion, query, addition, modification, saving, loading and exit.
2, Outline design
(1) Module composition of the program and functions of each function:
Module composition of the program:
Main function: main();
Output data function: printf();
Read data function: scanf();
Display record function: Display();
Delete record function: shanchu();
Search record function: chaxun();
User defined screen clearing function: system("cls");
User defined input function: input();
Character input function: getchar();
Modify data function: xiugai();
Save data function: baocun();
Sorting data function: paixu();
Main functions of each function:
Output data function: output data at any time;
Read data function: read the input data information;
Display menu function: displays the main menu available for selection;
Display record function: displays all the information entered in the address book;
Delete record function: displays all the input information of the address book to be deleted;
Search record function: displays all the input information of the address book to be queried;
User defined screen clearing function: clear the information left by the previous operation;
User defined input function: enter the members of the address book;
Character input function: input a character from the terminal and return in case of enter;
Modify data function: modify the member information of the address book;
Save data function: saves the member information of the address book;
Sort data function: sort the member information of the address book;
(2) Definition of abstract data type in program:
User state structure
User
{
No.:
Name:
Telephone;
Age;
Email:
Address;
}
(3) Overall flow chart
According to the above analysis, the design of the program system can be divided into the following modules: insert, display, delete, query, modify, save and exit.
3, Detailed design
(1) Main menu
The main menu is generally designed to be concise and only provide function calls for input, processing and output. Each function module is selected in menu mode.
(2) Display module
This module displays all records. The flow chart is as follows:
(3) Modify module
This module first calls the lookup function to find the information to be modified, and then the user modifies the information as needed. The flow chart is as follows:
(4) Insert module
This module is an insertion information module. After insertion, call the save function to save the inserted data, and support the insertion of multiple pieces of information.
(5) Delete module
This module first uses the search module to find the information to be deleted, and then determines whether to delete the information according to the user's choice
A call to the Save function. The flow chart is as follows:
4, Code display
(1) Main menu
int menu_select() { char c; do{ system("cls"); Add record ***************\n"); printf("\t\t\t**************│ 2. Display record│****************\n"); printf("\t\t\t**************│ 3. Delete record│****************\n"); printf("\t\t\t**************│ 4. Query record│****************\n"); printf("\t\t\t**************│ 5. Modify record│****************\n"); printf("\t\t\t**************│ 6. Keep records│*****************\n"); printf("\t\t\t**************│ 7. sort record│*****************\n"); printf("\t\t\t**************│ 0. Exit program│*****************\n"); printf("\t\t\t**************└──────---┘****************\n"); printf("\t\t Please select(0-7):"); c=getchar(); }while(c<'0'||c>'7'); return(c-'0'); }
(2) Display module
void Display(Person per[],int n) { Inti; printf("--------------------------------------------------------------------- \n"); core,per[i-1].name,per[i-1].age,per[i-1].num,per[i-1].adds,per[i-1].email); if(i>1&&i%10==0) { printf("\t-----------------------------------\n"); printf("\t"); system("pause"); printf("\t-----------------------------------\n"); } } printf("--------------------------------------------------------------------- \n"); system("pause");
(3) Modify module
void xiugai(Person per[],int n) { char s[20]; int i=0; printf("\t Please enter the name in the record you want to modify:"); scanf("%s",s); ame,s)!=0&&i<n) i++; if(i==n) { printf("\t This person is not in the address book!\n"); return; } printf("\t number:"); scanf("\t%d",&per[i].score); printf("\t full name:"); scanf("\t%s",per[i].name); printf("\t Age:"); scanf("\t%s",per[i].age); printf("\t Telephone number:"); scanf("\t%s",per[i].num); printf("\t postal address:"); scanf("\t%s",per[i].adds); printf("\t E-mail:"); scanf("\t%s",per[i].email); printf("\t Modified successfully"); }
(4) Insert module
int Input(Person per[],int n) { int i=0; char sign,x[10]; while(sign!='n'&&sign!='N') { printf("\t number:"); scanf("\t%d",&per[n+i].score); printf("\t full name:"); scanf("\t%s",per[n+i].name); printf("\t Age:"); scanf("\t%s",per[n+i].age); printf("\t Telephone number:"); scanf("\t%s",per[n+i].num); printf("\t Corresponding Address :"); scanf("\t%s",per[n+i].adds); printf("\t E-mail:"); scanf("\t%s",per[n+i].email); gets(x); printf("\n\t Continue adding?(Y/N)"); scanf("\t%c",&sign); i++; } return(n+i); }
(5) Delete module
int shanchu(Person per[],int n) { char s[20]; int i=0,j; printf("\t Please enter the name you want to delete from the record:"); scanf("%s",s); while(strcmp(per[i].name,s)!=0&&i<n) i++; if(i==n) { printf("\t This person is not in the address book!\n"); return(n); } for(j=i;j<n-1;j++) { strcpy(per[j].num,per[j+1].num); strcpy(per[j].name,per[j+1].name); strcpy(per[j].age,per[j+1].age); strcpy(per[j].adds,per[j+1].adds); strcpy(per[j].email,per[j+1].email); } printf("\t\t\t Successfully deleted!\n"); return(n-1); }
(6) Query module
void chaxun(Person per[],int n) { int m; printf("\t\n Please select query method:\n"); printf("\t┌──────---┐\n"); printf("\t│1------Name query│\n"); printf("\t│2------Telephone inquiry│\n"); printf("\t│3------Address query│\n"); printf("\t│4------return │\n"); printf("\t└──────---┘\n"); printf("Please select:"); scanf("%d",&m); while(m!=1&&m!=2&&m!=3&&m!=4) { printf("Input error, please select again:"); scanf("%d",&m); } if(m==1) { char s[20]; int i=0; printf("\t Please enter the name you want to query:"); scanf("\t%s",s); while(strcmp(per[i].name,s)!=0&&i<n) i++; if(i==n) { printf("\t This person is not in the address book!\n"); return; } printf("\t Person number: %d\n",per[i].score); ge); printf("\t Telephone number: %s\n",per[i].num); printf("\t postal address: %s\n",per[i].adds); printf("\t E-mail: %s\n",per[i].email); } ; if(m==2) { char s[20]; int i=0; printf("\t Please enter the phone number you want to query:"); scanf("\t%s",s); while(strcmp(per[i].num,s)!=0&&i<n) i++; if(i==n) { printf("\t This person is not in the address book!\n"); return; } printf("\t Person number: %d\n",per[i].score); ame); printf("\t This person's age: %s\n",per[i].age); printf("\t postal address: %s\n",per[i].adds); printf("\t E-mail: %s\n",per[i].email); } ; if(m==3) { char s[20]; int i=0; printf("\t Please enter the address you want to query:"); scanf("\t%s",s); while(strcmp(per[i].adds,s)!=0&&i<n) i++; if(i==n) { printf("\t This person is not in the address book!\n"); return; } printf("\t Person number: %d\n",per[i].score); ame); printf("\t This person's age: %s\n",per[i].age); printf("\t Telephone number: %s\n",per[i].num); printf("\t E-mail: %s\n",per[i].email); } ; }
(7) Sorting module
void paixu(Person per[],int n) { int i,j; um,per[j+1].num))>0) { strcpy(per->num,per[j].num); strcpy(per->name,per[j].name); strcpy(per->age,per[j].age); strcpy(per->adds,per[j].adds); strcpy(per->email,per[j].email); strcpy(per[j+1].num,per->num); strcpy(per[j+1].name,per->name); strcpy(per[j+1].age,per->age); strcpy(per[j+1].adds,per->adds); strcpy(per[j+1].email,per->email); } } printf("Sorting succeeded!\n"); }
5, Test results
(1) Main menu
(2) Show all information
(3) Insert information
(4) Find module
First step
Step 2
Step 3
Step 4
(5) Delete module
(6) Modify module
First step
Step 2
6, Summary
For many students, many grammar rules about C language in class sound very boring and difficult to remember. Rote memorization is not advisable. However, to use C language as a tool to solve practical problems, we must master it. Through computer practice, you will have a perceptual understanding of grammar knowledge and deepen your understanding of it. On the basis of understanding, you will naturally master the grammar provisions of C language. I think I understand some contents in class, but I will find the deviation of the original understanding in computer practice, which further consolidates the learned knowledge. Moreover, it is also a great challenge to learn systematic knowledge in design. The lack of knowledge in one aspect will affect the design of the whole program.
I think the final homework is very meaningful for beginners and will greatly improve their practical ability. Through the course design, you will have a new understanding of many functions and learn to use a variety of functions. I've talked a little more with you today, and I really hope you can know what to do and what to do in the future. Making choices has never been a difficult problem, but confusion is. Don't be busy for the sake of being busy. No matter what choice you make, as long as you can insist, the future will not be bad.
All right. Today's address book management system does not know whether you have mastered it. If you have not mastered it, you must watch it again and again, so that you can understand all the knowledge covered in it. I hope everyone can successfully complete their class assignments. I also hope that you can realize your unfulfilled wishes this year in the last month of 2021, I hope I can get your little attention here. Thank you very much!
In the follow-UP, the UP master will release more project source codes and learning materials. I hope you can continue to pay attention to it and reply to any questions. If you want C/C + + learning materials and the source code of other projects, you can add group [1083227756] to understand. Interested in the future development of programmers, you can focus on WeChat official account: Fox's encoding time, hope to learn progress with everyone!!!