Practical programming-advanced filtering and programming Filtering

Source: Internet
Author: User

Practical programming-advanced filtering and programming Filtering

In my office work last semester, I used advanced filtering many times. For example, I have a copy of the student's correct name, student ID, and other information in the department. I wrote a summary table above, you need to identify these students among thousands of people and check if their information is correct. At this time, we often need to use advanced filtering in Excel. However, I have tried many times before and found that WPS advanced filtering cannot be used. Later I switched to Office2013, therefore, it has caused a lot of trouble to work. Every time Baidu takes a long time to find out all the data through various methods. If the data volume is not big enough, you can check it one by searching, but this is always not good. Time is money. Who will spend so much time doing this inefficiency.

Sometimes, we find a student ID, but if the student ID is wrong, a person may be lost. If you search by name, there may be people with the same name (Advanced filtering may cause problems if the same name is used), resulting in a further increase in workload.

Previously, I wrote a work-study-checking program, which can efficiently verify data. Here we have modified it to implement two verification methods, which can be used in combination. Currently, no problems have been found, and it will be easier for future work.

/* The code is compiled in the VC 6.0 cpp Program */
# Include <stdio. h>
# Include <string. h>
# Include <Windows. h>

Void BiduiXuehao ();
Void BiduiName ();

Int main (void)
{
Char xuanze [2];
Printf ("Please put the correct data into E: \ assets data .txt before the program is officially started, and put the summary table (the data to be checked) into E: \ core-to-data .txt. format: the student ID. Please continue after preparation! \ N ");
System ("pause ");
While (1)
{
System ("cls ");
Printf ("Enter the corresponding serial number, select the filtering mode: \ n1, and check by name (if the name is incorrect, the user may not be found) \ n2. Pass the student ID check (if the student ID is incorrect, the student ID may not be found) \ n ");
Printf ("Enter and select :");
While (1)
{
Scanf ("% s", xuanze );
If (strlen (xuanze)> 1)
Printf ("Please reselect :");
Else
Break;
}
Switch (xuanze [0])
{
Case '1': BiduiName (); break;
Case '2': BiduiXuehao (); break;
Default: printf ("input error! "); System (" cls "); break;
}
}
Return 0;
}

Void BiduiName (void)
{
Int hang = 0, flag = 0;
FILE * pRight = fopen ("E: \ parse data .txt", "r ");
Char RightName [20], HeduiName [20], RightNum [20], HeduiNum [20];
System ("cls ");
While (fscanf (pRight, "% s", RightName, RightNum )! = EOF) // if the person in the correct version is not finished, continue
{
Hang = 0;
Flag = 0;
FILE * pHedui = fopen ("E :\\ .txt", "r"); // re-open the FILE to find
While (fscanf (pHedui, "% s", HeduiName, HeduiNum )! = EOF)
{
Hang ++;
If (strcmp (RightName, HeduiName) = 0) // if the name is the same, this student is found in the summary table, so the student IDs are different.
{
Printf ("% s.", hang, RightName found in row % d in the summary table );
If (strcmp (RightNum, HeduiNum) = 0) // if the student ID is correct, the information is output.
{
If (flag = 2)
Printf ("% s with the same name found, the student ID of this row in the summary table is correct \ n", RightName );
Else
Printf ("Ta's student ID is correct. \ N ");
Flag = 1;
Break;
}
Else
{
Printf ("Ta's student ID is incorrect. Correct: % s. Here: % s. The search will continue here to see if the same name exists. \ T ", RightNum, HeduiNum );
Flag = 2;
Continue;
}
}
}
If (flag = 1) // you have found the correct one.
{
Continue;
}
Else if (flag = 2)
Printf ("Other % s not found in the summary table. So his student ID is wrong. \ N ", RightName );
Else // This student is not found at the end of the file
{
Printf ("% s student is not found in the summary table. We recommend that you use the Ta student ID to check whether the name in the summary table is incorrect \ n", RightName );
}
Fclose (pHedui );
}
Fclose (pRight );
System ("pause ");
}


Void BiduiXuehao (void)
{
Int flag = 0;
FILE * pRight = fopen ("E: \ parse data .txt", "r ");
Char RightName [20], HeduiName [20], RightNum [20], HeduiNum [20];
System ("cls ");
While (fscanf (pRight, "% s", RightName, RightNum )! = EOF) // if the person in the correct version is not finished, continue
{
Flag = 0;
FILE * pHedui = fopen ("E :\\ .txt", "r"); // re-open the FILE to find
While (fscanf (pHedui, "% s", HeduiName, HeduiNum )! = EOF)
{
If (strcmp (RightNum, HeduiNum) = 0) // if the student ID is the same, this student is found in the summary table, so they are compared to whether their names are the same.
{
If (strcmp (RightName, HeduiName) = 0) // if the name is correct, the output information is displayed.
{
Printf ("% sTa's student ID is correct. \ N ", RightName );
Flag = 1;
Break;
}
Else
{
Printf ("the name of the students whose student ID is % s is incorrect. Correct: % s. Total table: % s ", RightNum, RightName, HeduiName );
Flag = 1;
}
}
}
If (flag = 1) // already found
{
Continue;
}
Else // This student is not found at the end of the file
{
Printf ("% s student ID: % s, but no persons with the same student ID \ n", RightName, RightNum are found in the summary table );
}

Fclose (pHedui );
}
Fclose (pRight );
System ("pause ");
}



I will not attach it here, because the experiment uses the information of students. If you are interested, you can try it yourself.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.