C language campus singer competition system

Source code click here

Operating environment: codeblocks

1 Introduction... 

1.1 Question posed... 

1.2 Knowledge points involved in this system... 

1.3 Functional requirements... 

2. Overall design... 

2.1 Function module design... 

2.2 Process design of main control main() function 

2.3 Data structure design... 

2.4 Sub-module design... 

2.4.1 Adding a logging module... 

2.4.2 Query record module... 

2.4.3 Updating the logging module... 

2.4.4 File reading and writing module... 

2.4.5 Other modules... 

2.4.5.1 Cryptographic Modules... 

2.4.5.2 Output Color Module...

2.4.5.3 Background Color Module... 

2.4.5.4 System Time Module... 

2.5 Function Description... 

3. Program implementation... 

3.1 Main interface... 

3.2 Submodule interface... 

3.2.1 Password verification interface (see chart 2)... 

3.2.2 Score entry (see chart 3)... 

3.2.3 Score display (see chart 4)... 

3.2.4 The average score of the judges (see chart 5)... 

3.2.5 Score sorting (see chart 6)... 

3.2.6 Score Lookup (See Chart 7)... 

3.2.7 Information modification (see chart 8)... 

3.2.8 Score deletion (see chart 9)... 

3.2.8 Password modification (see chart 10)... 

3.2.8 Password modification (see chart 10)... 

4 Summary... 

4.1 Program debugging situation... 

4.2 My impressions in program design... 

1.1 Question raised

In this experiment, the following problems are mainly realized:

1. Enter player data (class, number, name, ten judges' scores and save the data to a file);

2. Output player data (class, number, name, total score, average score after removing the highest and lowest scores);

3. Display the average score of the judges (the average score of the ten judges is sorted out, and judge who is the strict judge and who is the gentle judge according to the level);

4. Realize the sorting of players (sorting according to the average score);

5. Result query (query by name, number, and operations such as modification and deletion can be performed after query);

6. Information modification (you can modify player information such as class, name, number, and the scores of some judges, and after modifying the scores, the average score and total score can be refreshed);

7. Delete scores (you can delete a player's score according to the player's number or name);

8. Modify the login password (protect the security of the program, realize the modification of the login password, enter the password five times, enter the wrong password five times, display the exit program, and remind the password viewing address. Just like the app's password retrieval function) ;

9. Enter the modification interface and want to return to the main menu but there is no function key, add a break statement to jump out of the loop

10 Deleting the score should show the player's score before, otherwise I don't know who to delete

11 Ability to modify the output color to make the prompt more eye-catching

12 can change the background color instead of a single black

13 There will be a buffer time for opting out

14 Time display at the top, get off work when the time comes

1.2 Knowledge points involved in this system

1. Structure variable: struct Student

     {

}stu[1000];

struct Student stu[1000],*p=stu; define global p->struct Student stu[] ;

2. Array: char cla[20] : input player class

         Char name[20] input player name

         Float score[10] Enter the scores of ten judges

char tempname[20] is used to define the temporary variable of the name

char tempcla[20] is used to define the temporary variable of the class

char password[20],key[20]; initial password

        3.循环:for(i=0;i<count;i++)

                     if(stu[count].num==stu[i].num) determines whether the entered player number is repeated

                     if(strcmp(searchname,stu[i].name)==0) find the name

                     if(searchnum==stu[i].num) find number

                  for(j=0;j<10;j++)

                      if(max<stu[count].score[j]);

                      max=stu[count].score[j]; Find the maximum score

                  for(k=0;k<10;k++)

                      if(max<stu[count].score[k]);

                      min=stu[count].score[k]; Find the minimum score

                  for(i=0;i<count;i++)

                      printf(); display data;

for(i=searchindex;i<count-1;i++)

strcpy(this[i].cla,this[i+1].cla);

            stu[i].num=stu[i+1].num; delete relevant information

       

 4. Function _

              void input(struct Student stu[]) player score input

              void print(struct Student stu[]) player score display

              void average(struct Student stu[]) The average score of the judges

              void sort(struct Student stu[]) Players are sorted by average score (score sorting sub-function)

              void projectsort(struct Student stu[]) score sorting

              void findnum(struct Student stu[]) find by number (score query sub-function)

              void findname(struct Student stu[]) search by name (score query sub-function)

              void find(struct Student stu[]) score query

              void del(struct Student stu[]) score deletion

void delnum(struct Student stu[]) delete according to the number (score delete sub-function)

void delname(struct Student stu[]) delete by name (score delete sub-function)

void change(struct Student stu[]) modify information

void read(struct Student stu[]) file import

void save(struct Student stu[]) file storage

int up() to modify the password

void save_password(char s[]) Save password modification

void hidepassword(char *pswd, unsigned maxlen) hides the password input

void color(const unsigned short textColor) color output

 5. branch _

     If statement:

          if(stu[count].num==stu[i].num) determines whether the input is a repeated number

          if(max<stu[count].score[j]); judge the maximum value

          if(min>stu[count].score[k]); judge the minimum value

          if(searchindex==-1) to determine whether the input data is valid

          if(strcmp(searchname,stu[i].name)==0) to determine whether the name exists

          if(count==0) judge whether player information is entered

          if(fread(&stu[i],sizeof(struct Student),1,fp)!=1) judge the number of bytes in the file

          if(key[i]!=password[i]) judge whether the password is correct          

               

            if else statement:

                  if(count==0)

                     printf("\n\nYou have not entered player information, please return to the menu to enter! \n");

                  else// otherwise output player information

            switch statement:

                  switch(choose)

                          case 1: // Score entry

                          case 2: // Score display and sorting

                          case 3: // All subject scores

                          case 4: // score sorting

                          case 5: // Score lookup         

                          case 6: // Score modification        

                          case 7: // Score deletion     

                          case 8: // Password modification        

                          case 0: // exit the system

     

          6. pointer _

                 struct Student this[1000],*p=this;

          7.goto statement ;

1.3 Functional requirements

  1. Enter the contestant's class, number, name, ten judges' scores
  2. Output the player's class, number, name, ten judges' scores, total score and average score with the highest and lowest scores removed
  3. Display the average score scored by each judge
  4. Sort the average scores of the players, with the highest scores at the front
  5. Search for player scores by number or name
  6. Can modify all player information
  7. Ability to delete player scores based on number or name
  8. Change login password
  9. Exit system

2. Overall design

2.1 Functional module design

              

2.2 Process design of main control main() function

2.3 Data structure design

1.struct Student //Define structure variables

    {

        char cla[20];//class

              int num;//Number

        char name[20];//name

        float score[10];//score

        float aver;//average score

        float sum;//total score

    }stu[1000];

struct Student stu[1000],*p=stu; //Define global p->struct Student stu[]

2.int count=0; //Define the global variable count, enter a player's information, and the count will increase by one;

3.float min,max,Max,Min;//Used to find the highest and lowest scores among the ten judges

4.int choose;//Used to feedback the user's input

5.int i, j; used to cycle input and output

7 char tempname[20]; 

char tempcla[20];//Define name and class temporary variables for sorting

8. int searchnum;//used to find the player number

9. char searchname[20];//used to find the student name

10.int sum2=0;//The number of input times used to cycle the password

2.4 Sub-module design

2.4.1 Add record module

2.4.2 Query record module

ID lookup

name lookup

show all

back to menu

turn up

2.4.3 Update record module

2.4.4 File reading and writing module

2.4.5  Other modules

2.4.5.1 Cryptographic Module

2.4.5.2 Output color module

2.4.5.3 Background color module

system("color 3E"); blue background

2.4.5.4 System Time Module

time_t timep; //system time

       struct tm *p_1;

       time (&timep);

       p_1=gmtime(&timep);

2.5 Function description

( 1 ) Input module

1 ) Function prototype: void input(struct student stu[ ])

2 ) Function:

Realize the input of the player's class number, name and ten judges' scoring, and save it in the file

3 ) Variables and types:

Float min , max : floating-point formal parameter variables, used to find the maximum and minimum values

Int ij : loop control variable

void save(struct Student stu[]); save data to file

char tempcla[10]={"-1"}; defines a temporary name string for pressing ( -1 ) to return to the menu

  ( 2 ) Output module

  1. Function prototype: void print(struct Student stu[])
  2. Function:

Realize the player's information output

  1. Variables and types:

sort(struct Student stu[]); Call the sorting function to sort the information and output

if(count==0) : use the global variable count to determine whether the data has been entered

( 3 ) The judges divide the modules equally

  1. Function prototype: void average(struct Student stu[])
  2. Function:

Calculate the average score scored by each judge

  1. Variables and types:

Int i: loop control variable

float aver[10] : average variable

float total[10]={0} : store the judges' scoring variable

( 4 ) Score sorting module

  1. Function prototype: void sort(struct Student stu[])
  2. Function: Sort the data of the players according to the average score
  3. Variables and types:

    char tempname[20];

char tempcla[20]; character temporary variable, used to store class name

int ij : loop control variable

float t: Intermediate variable for ranking scores

int t1; the intermediate variable of the sort number

     ( 5 ) Score lookup module

 

 

  1. Function prototype: void findnum(struct Student stu[]) : query by number

             void findname(struct Student stu[]) : query by name

             void find(struct Student stu[]) : query

  1. Function: Realize the query of data

         Search by name number

  1. Variables and types:

    int choose, n; Integer variable specifies the next operation

     int i; loop control variable

     char searchname[20]; character variable is used to find the name

     int searchnum; Integer variable is used to search number

( 6 ) Information modification

  1. Function prototype: void changescore(struct Student stu[])
  2. Function: Realize the modification of player information and update the modified data
  3. Variables and types:

   int ij : loop control variable

     int choose : the next operation variable

int searchnum, tempnum : modify the number of temporary variables

( 7 ) Delete the score module

 

 

  1. Function prototype:

            void delnum(struct Student stu[]) : delete by number

            void delname(struct Student stu[]) : delete by name

            void dell(struct Student stu[]) : delete data

  1. Function: Realize the deletion of data, which can be deleted according to the name and number, and the remaining information can be displayed after deletion
  2. Variables and types:

Int i: control loop variable

Int choose : Integer variable, used for the next step

   char tempname[10]={"-1"}; character variable, used to input name and return operation

( 8 ) Modify password

 

 

  1. Function prototype:

        int up() ; password modification

        void save_password(char s[]) ; save the modified password

        void yincangpassword(char *pswd, unsigned maxlen) ; hide password input

  1. Function:

       Realize the input and change of password, and save it in the file

  1. Variables and types:

    FILE *fp= fopen("password.txt","w+"); Define the file pointer

    char buff = '\0';

4 ) Description:

     Referring to the csdn source code, I don't fully understand the input of the hidden password.

3. Program implementation

3.1 Main interface

Chart 1

3.2 Submodule interface

3.2.1 Password verification interface (see chart 2)

Chart 2

3.2.2 Score entry (see chart 3)

 

Chart 3

3.2.3 Score display (see chart 4)

Chart 4

3.2.4 Average score of judges (see chart 5)

Chart 5

3.2.5 Score Sorting (See Chart 6)

Chart 6

3.2.6 Score Lookup (See Chart 7)

Chart 7

3.2.7 Information modification (see chart 8)

Chart 8

3.2.8 Score deletion (see chart 9)

Chart 9

3.2.8 Password modification (see chart 10)

 

4 Summary

4.1 Program Debugging

The program runs without errors and without warnings

4.2 My thoughts on program design

    When I first chose this campus singer competition system project, I thought it was a bit similar to the student performance management system version, and it would be easier to do. Because my programming level is not very good, it took me a long time just to conceive the framework. In order to avoid detours, I also referred to the video of the student performance management system at station B, the source code of the student performance management system on csdn, and the most important template is the student management system v2.0 in the book.

Let's talk about programming first: According to the requirements of the topic, input and output, judges' scoring, grade sorting, data query, adding student data, storage, import, and exit are required. According to my own ideas, I included the judge's score in the input player information. For convenience, I directly put the storage function at the end of each operation to realize automatic storage instead of manual storage. After all, I often forget ctrl+s when programming. In addition, in order to protect the security of the program, I set a password to log in to the system. The user has five chances to enter the password. Once the wrong password is entered five times, the program will exit. Later, for the comfort of the user experience, I added a super low-profile function like QQ forgetting the password to retrieve the password, that is, prompting the user to view the login password in the file where the password is saved.

For the robustness of the program, I did not use a loop to input data, but defined a global variable to record the number of players entered. According to real life, the number of the players is unique, but there may be cases of the same name in the same class. So I only checked the numbers for duplicates. However, when modifying information or deleting information, it is necessary to use an independent number to delete the information of the person with the same name. At the beginning, I defined the judges’ scores as integer variables, but I accidentally saw decimals in the scores on TV, so I changed them to floating-point variables, and gave hints and specifications for the input range. After the input is completed, there will be a continuous input operation and an exit operation for the user to choose.

I have added an option of judges' average score, which can display the average score of each judge's score, and then judge who is the strict (ruthless) referee and who is the benevolent (loose) referee.

In the test of searching for scores, I found that after searching the player information, I couldn’t proceed to the next step. There was only a bare display of the searched player information. In order to improve the function, I added the option of modifying and deleting after the search was successful.

For information modification. I realized that all the information of the contestants can be modified, and after modifying the judges' scores, the average score and total score can be refreshed and displayed.

For changing the password, I hide the password with *, and at the stage of changing the password, remove the process of verifying the old password, which saves unnecessary trouble for open source files (but it is very easy to be tampered with by others), and then directly Enter a new password and remind the user to log out and log in again.

On the UI interface, I used my favorite blue as the background color, and displayed the pattern of music symbols on the login interface, which is closer to the singer competition. After entering the wrong password for 5 times, I use red output font to prompt the user to find the password, and the red font is more eye-catching.

The biggest achievement of this project is that one person completed the entire project, and corrected errors in the process without seeking help from others. When you see that the program compiles successfully and without warnings, it feels like all the hard work is worth it. It took about seven days before and after. Sometimes when encountering obstacles, I searched for information or waited for the idea to come out tomorrow. The process was a bit tortuous.

Especially when I was referring to the program, I found out that it could be handled in this way, which opened my eyes and made me extremely excited. The successful project this time has strengthened my confidence in programming, strongly enhanced my interest in programming, consolidated the knowledge points I have learned, and allowed me to apply what I have learned. Not only that, but I also learned new knowledge points and reduced my knowledge blind spots.

I feel that all the programs are not written by myself, which is my shortcoming. For example, I borrowed the code from csdn to hide the password. In addition, the functions of the program are still not perfect. For example, when exiting the information query, you need to click multiple times to enter, the information modification can only be modified once and cannot be repeated, the sorting can only be sorted by the average score and not by the number, etc.

But it is precisely because of the shortcomings that I have the motivation to move forward. I will continue to improve and enrich the system and improve it with new knowledge. In terms of myself, I will strictly demand myself and give my life a satisfactory answer!

Guess you like

Origin blog.csdn.net/qq_62315940/article/details/127890997