C ++ compiles a Student Score Management System

Source: Internet
Author: User

/* (Start of program header annotation)
* Copyright and version Declaration of the program
* Copyright (c) 2011, a student from the computer College of Yantai University
* All rights reserved.
* File name: C ++ Student Achievement Management System
* Author: Liu jiangbo
* Completion date: January 1, June 26, 2012
* Version No.: v.626

* Description of tasks and Solutions
* Problem description:

Use C ++ to compile a Student Achievement Management System

1. The following functions can be implemented:

Cout <"〓★☆1. Increase student scores ☆★〓 "<Endl;
Cout <"〓★☆2. Show student scores ☆★〓 "<Endl;
Cout <"〓★☆3. Sort statistics result ☆★〓 "<Endl;
Cout <"〓★☆4. Search for student scores ☆★〓 "<Endl;
Cout <"〓★☆5. Delete student scores ☆★〓 "<Endl;
Cout <"〓★☆6. Modify student information ☆★〓 "<Endl;
Cout <"〓★☆0. Exit the System Safely ☆★〓 "<Endl;


2. store information with a linked list

* End the comment in the program Header
*/

[Cpp]
<Span style = "font-size: 16px;" >#include <iostream>
# Include <fstream>
# Include <string. h>
# Include <conio. h> // use getch ();
Using namespace std;
 
// When there are too many threads, there are too many Student classes when there are too many threads ﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Class Student
{
Public:
Char name [20];
Char Id [20];
Int Cnum; // C ++ course score
Int Mnum; // compile the course score
Int Enum; // embedded operating system course score
Int sum; // total score
Student * Next;
Void Input ()
{
Cout <"\ t enter the student's name:"; cin> name;
Cout <"\ t enter the student's student Id:"; cin> Id;
For cout <"\ t, enter the C ++ course score:"; cin> Cnum;
For cout <"\ t, enter the score of the compilation Course:"; cin> Mnum;
For cout <"\ t, enter the score of the embedded operating system course:"; cin> Enum;
Sum = Cnum + Mnum + Enum;
}
Void ReadFile (istream & in)
{
In> name> Id> Cnum> Mnum> Enum> sum;
}
Void Show ()
{
Cout <"name:" <name <endl <"student Id:" <Id <endl <"C ++:" <Cnum <endl
<"Assembly:" <Mnum <endl <"embedded operating system:" <Enum <endl <"total score: "<sum <endl;
}
};
 
// When there are too many threads, there are too many Studentmassage classes when there are too many threads ﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Class Studentmassage
{
Public:
Studentmassage ();
~ Studentmassage ();
Void ShowMenu ();
Void Find ();
Void Save ();
Void ModifyItem ();
Void RemoveItem ();
Void Swap (Student *, Student *);
Void Sort ();
// Void Unpass ();
Int ListCount ();
// Void Average ();
Void Display ()
{
For (Student * p = Head-> Next; p! = End; p = p-> Next)
P-> Show ();
Cout <"enter any character! Continue ...... ";
Getch ();
}
Void AddItem ()
{
End-> Input ();
End-> Next = new Student;
End = End-> Next;
Cout <"added successfully! "<Endl;
Cout <"enter any character! Continue ...... ";
Getch ();
}
Private:
Student * Head, * End;
Ifstream in;
Ofstream out;
Student * FindItem (char * name)
{
For (Student * p = Head; p-> Next! = End; p = p-> Next) // If the match is successful, the previous pointer is returned. If the match is unsuccessful, null is returned.
If (! Strcmp (p-> Next-> name, name) return p;
Return NULL;
}
Student * FindID (char * Id)
{
For (Student * p = Head; p-> Next! = End; p = p-> Next) // If the match is successful, the previous pointer is returned. If the match is unsuccessful, null is returned.
If (! Strcmp (p-> Next-> Id, Id) return p;
Return NULL;
}
};
 
// When there are too many constructor operators, and there are too many such constructor operators ﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Studentmassage: Studentmassage ()
{
Head = new Student;
Head-> Next = new Student;
End = Head-> Next;
In. open ("sort.txt ");
If (! In)
Cout <"this is a new system with no student information. Enter. "<Endl;
Else
{
While (! In. eof ())
{
End-> ReadFile (in );
If (End-> name [0] = '\ 0') break;
End-> Next = new Student;
End = End-> Next;
}
In. close ();
Cout <"\ t read student information! "<Endl;
}
}
 
// When there are too many constructor functions, there are too many constructor functions ﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Studentmassage ::~ Studentmassage ()
{
Save ();
For (Student * temp; Head-> Next! = End ;)
{
Temp = Head-> Next;
Head-> Next = Head-> Next;
Delete temp;
}
Delete Head, End;
}
 
// When there are too many threads, there are too many threads in the navigation menu ﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Void Studentmassage: ShowMenu ()
{
Cout <"************************************ **************************************** * *** "<endl;
Cout <"〓 ☆ ☆ ☆ ☆" <endl;
Cout <"〓★★★★★★★★★★★★★★★★★〓 "<Endl;
Cout <"〓★☆1. Increase student scores ☆★〓 "<Endl;
Cout <"〓★☆2. Show student scores ☆★〓 "<Endl;
Cout <"〓★☆3. Sort statistics result ☆★〓 "<Endl;
Cout <"〓★☆4. Search for student scores ☆★〓 "<Endl;
Cout <"〓★☆5. Delete student scores ☆★〓 "<Endl;
Cout <"〓★☆6. Modify student information ☆★〓 "<Endl;
Cout <"〓★☆0. Exit the System Safely ☆★〓 "<Endl;

Cout <"\ n \ t please select :";
}
 
// When there are too many rows, there are too many rows, and so on ﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Void Studentmassage: Find ()
{
Char name [20], Id [10];
Int x;
Student * p = NULL;
Cout <"\ n \ t ****************************** * ** \ n ";
Cout <"\ t ※1. Search by Student name \ n \ t ※2. Search by student ID ";
Cout <"\ n \ t ****************************** * ** \ n select: ";
Cin> x;
Switch (x)
{
Case 1: {cout <"\ t enter the name of the student to be searched:"; cin> name;
If (p = FindItem (name ))
{
P-> Next-> Show ();
Cout <"enter any character! Continue ...... ";
Getch ();
}
Else
{
Cout <"\ t does not find the student with this name! "<'\ N' <endl;
Cout <"enter any character! Continue ...... ";
Getch ();
}
} Break;
Case 2:
{
Cout <"\ t enter the student Id:"; cin> Id;
If (p = FindID (Id ))
{
P-> Next-> Show ();
Cout <"enter any character! Continue ...... ";
Getch ();
}
Else
{
Cout <"\ t cannot find the student to learn well! "<'\ N' <endl;
Cout <"enter any character! Continue ...... ";
Getch ();
}
} Break;
}

}
 
// Zookeeper has been released. zookeeper has been released. zookeeper has been modified ﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Void Studentmassage: ModifyItem () // modify Information
{
Char name [20];
Student * p = NULL;
Cout <"\ t enter the name of the person to be modified:"; cin> name;
If (p = FindItem (name ))
{
Cout <"\ t has found student information. Please enter new information! "<Endl;
P-> Next-> Input ();
Cout <"modified successfully! "<Endl;
Cout <"enter any character! Continue ...... ";
Getch ();
}
Else
{
Cout <"\ t not found! "<Endl;
Cout <"enter any character! Continue ...... ";
Getch ();
}
}
 
// Zookeeper has been deleted ﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Void Studentmassage: RemoveItem () // delete information
{
Char name [20];
Student * p = NULL, * temp = NULL;
For cout <"\ t, enter the name of the student to be deleted:" <endl; cin> name;
If (p = FindItem (name ))
{
Temp = p-> Next;
P-> Next = p-> Next;
Delete temp;
Cout <"\ t deleted successfully! "<Endl;
Cout <"enter any character! Continue ...... ";
Getch ();
}
Else
{
Cout <"\ t not found! "<Endl;
Cout <"enter any character! Continue ...... ";
Getch ();
}
}
 
// When there are too many threads, there are too many threads, too many threads //﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Void Studentmassage: Swap (Student * p1, Student * p2) // exchange the data fields of two combox Variables
{
Student * temp = new Student;
Strcpy (temp-> name, p1-> name );
Strcpy (temp-> Id, p1-> Id );
Temp-> Cnum = p1-> Cnum;
Temp-> Mnum = p1-> Mnum;
Temp-> Enum = p1-> Enum;
Temp-> sum = p1-> sum;

Strcpy (p1-> name, p2-> name );
Strcpy (p1-> Id, p2-> Id );
P1-> Cnum = p2-> Cnum;
P1-> Mnum = p2-> Mnum;
P1-> Enum = p2-> Enum;
P1-> sum = p2-> sum;

Strcpy (p2-> name, temp-> name );
Strcpy (p2-> Id, temp-> Id );
P2-> Cnum = temp-> Cnum;
P2-> Mnum = temp-> Mnum;
P2-> Enum = temp-> Enum;
P2-> sum = temp-> sum;
}
 
// When there are too many threads, there are too many threads, too many threads //﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Int Studentmassage: ListCount () // counts the total number of records in the current linked list. An integer is returned.
{
If (! Head)
Return 0;
Int n = 0;
For (Student * p = Head-> Next; p! = End; p = p-> Next)
{
N ++;
}
Return n;
}
 
// When there are too many threads, there are too many threads, too many threads //﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Void Studentmassage: Sort () // Sort the current linked list
{
Cout <"Sorting..." <endl;
Student * p = NULL, * p1 = NULL, * k = NULL;
Int n = Studentmassage: ListCount ();
If (n <2)
Return;
For (p = Head-> Next; p! = End; p = p-> Next)
For (k = p-> Next; k! = End; k = k-> Next)
{
If (p-> sum> k-> sum)
{
Studentmassage: Swap (p, k );
}
}
Cout <"Sorted! "<Endl;
Getch ();
Return;
}
 
// Zookeeper has been written into zookeeper without being transferred. The function is saved in zookeeper without being transferred ﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Void Studentmassage: Save ()
{
Out. open ("sort.txt ");
For (Student * p = Head-> Next; p! = End; p = p-> Next)
Out <p-> name <"\ t" <p-> Id <"\ t" <p-> Cnum <"\ t"
<P-> Mnum <"\ t" <p-> Enum <"\ t" <p-> sum <'\ n ';
Out. close ();
}
 
// Zookeeper has been written into zookeeper and zookeeper has been written into the main function ﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌
Int main ()
{
Int x, I = 0;
Bool quit = false;
Cout <"\ t §" <endl;
For (I = 0; I <3; I ++)
Cout <"\ t ◎" <endl;
Cout <"\ t ◎★★★★[Welcome to the Student Achievement Management System]★★★★◎ "<Endl;
For (I = 0; I <3; I ++)
Cout <"\ t ◎" <endl;
Cout <"\ t § \ n" <endl ;;
Studentmassage Grade;
Cout <"press any key to start ...... ";
Getch ();
While (! Quit)
{
System ("cls ");
Grade. ShowMenu ();
Cin> x;
Switch (x)
{
Case 0: quit = true; break;
Case 1: Grade. AddItem (); break;
Case 2: Grade. Display (); break;
Case 3: Grade. Sort (); break;
Case 4: Grade. Find (); break;
Case 5: Grade. RemoveItem (); break;
Case 6: Grade. ModifyItem (); break;
}
}
Return 0;
} </Span>
 

Author: sdliujiangbo

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.