This article is a model article of programming practice report. For more information, please refer to the following:
Editor of this article: yjbys.com
1, experimental purpose and content
Through course design, we skillfully use C++ for object-oriented programming, establish an object model, reduce the complexity of software, improve the reusability and maintainability of software, improve the productivity of software, and master the object-oriented programming technology comprehensively.
Students are required to independently complete all the contents of the internship subject under the guidance of the instructor, including:
(1) Collect relevant technical data through investigation and practice;
(2) Master the basic steps and methods of design projects;
(3) According to the requirements of the project, the computer experiment is debugged.
2. Topic 1: Seek the average score of the competition.
2. 1 program content
In sports, literary competitions, elections and other classified projects, in order to be fair, it is often necessary to remove a highest score and a lowest score after N judges score, and then take the average score. When n is large (this question is set to 9), the two highest scores and the two lowest scores should be removed, and then the average score should be taken. The algorithm is realized by programming.
2.2 Experimental Scheme Design and Structure
(1) demand analysis:
Enter 9 judges to score, and the final result of the program is the average score after removing the highest score and the lowest score.
(2) Design structure:
Overall structure
?
data structure
Score nine judges, from a[0] to a[9].
2.3 Design process
(1) Establish iostream/ofstream/fstream, input, output and iostream objects, and establish ifndef to define pre-programmed commands and structural data.
(2) According to the flow chart, establish the main function and use the for loop.
(3) Run the main function for debugging.
2.4 Operating results
3. Topic 2: Competition game
3. 1 program content:
23 Matches Game: Two players start to own 23 matches (or sticks). Each player takes turns to remove 1, 2 or 3 matches, and the one who gets the last match loses. Write a program to play this game on the computer.
3.2 Experimental Scheme Design
(1) demand analysis:
Running this program can make people play 23 games with computers.
(2) Design ideas:
If the computer can match four or less first, the computer will win.
3.3 Design process
(1) Establish iostream/ofstream/fstream, input, output and iostream objects, and establish ifndef to define pre-programmed commands and structural data.
(2) According to the design idea, use if to judge the sentence design.
(3) establish the main function
(4) Run the main function for debugging.
?
3.4 Operation results
4. Topic 3: football scores
4. 1 Design content:
problem description
The football league adopts the double-cycle system of home and away games, with 3 points for each win, 0 points for each draw 1 point and 0 points for each loss. When the scores of two teams (or two teams) are the same, the goal difference (that is, the difference between the number of goals scored and the number of goals conceded) is the most. If the goal difference is the same, the number of goals is the highest. If it is still the same, draw lots. Try to compile a program to count the points and rankings of each team after the latest round of competition.
basic requirement
The structure of the score table is as follows: team name (no more than 15 characters), played games, won games, draw games, lost games, goals, goals conceded and scores. The integral table is placed in a text file. The results of the latest round are entered from the keyboard in the form of home team name (available code), visiting team name (available code), home team score (i.e. number of goals) and visiting team score (i.e. number of goals). The program should modify the scores and rankings of each team according to the results of this round, and the latest score table is still in the original score file and displayed on the screen at the same time.
test data
You can choose the data input of China A League or A-B League to see if it is consistent with the data published in the newspaper.
4.2 Design scheme:
Define a team class and an object array, and each team is an object of the team class. Because the number of teams participating in the tournament is fixed, each team is stored in the array element of the object array. Input the match results of two teams at a time, corresponding to the relevant data of the teams (matches, wins, goals, etc.). ) can be modified. After the competition results are input, the league ranking method (the object array is the parameter and the integral is the ranking element) is called to discharge the ranking and output it.
5. Design features and experience:
After a semester of study and computer practice, I have a further understanding of C++ language. If I want to learn it well, I should focus on practice. Through constant computer operation, I can learn it better. Through practice, I also found many shortcomings, such as various control structures and statements, arrays, pointer arrays, character arrays, dynamic arrays, definition and calling methods of functions. The specific application of function in programming: and the range of variable storage characteristics and identifiers. Through practice, I have learned and improved these aspects. Curriculum design is not only a task, but also a challenge and experience. In the course design, in order to facilitate the use, the insufficient knowledge is emphatically analyzed and understood, and the file operation has been greatly improved in this process. Through practice, we can enhance our ability to understand and apply knowledge.
?
?
?
?
?
refer to
[1], Yang Changxing, Liu Weiguo, C++ Programming, China Railway Press, 2008.
appendix
Subject 1 experimental source code:
# include & ltstdio.h & gt
# include & ltiostream.h & gt
void main()
{
int a[9],I,j,temp,b=0,s;
Cout & lt& lt Please comment: "< & ltendl"
for(I = 0; I<9; i++)
{
CIN & gt; & gta[I];
}
for(I = 0; I<9; i++)
for(j = I; j & lt9; j++)
{
if(a[I]& lt; =a[j])
{
temp = a[I];
a[I]= a[j];
a[j]= temp;
}
}
for(I = 2; I<7; i++)
{
b = b+ a[I];
}
s = b/5;
Cout & lt& lt "The final score is:"
}
?
?
?
?
?
?
?
?
?
?
?
?
Topic 2 Experimental Source Code:
# include & ltstdio.h & gt
# include & ltstdlib.h & gt
# include & ltiostream & gt
int getMin(int a,int b)
{
Returns an<b? A: b;
}
int main()
{
Printf ("Game on \ n");
int count = 23
Int input;
Int computer input;
While (true)
{
Printf ("There are %d matches left, please take a match: \n", count);
Printf(" 1。 Matches ");