C++ Marriage Work Three Years Schoolgirl Practice Questions Big Homework

background:

After the author finishes, I think the topic is quite interesting, suitable for understanding C++

 Topic requirements:

Homework (1)

1. A class has n seats, numbered: 1~n. One student per seat. In order to be fair, the teacher should ask all the students questions during the lecture. The method for selecting students is:

1) According to the seat number, start from the first one, count backwards, and ask the student at m. Mark the classmate as a "student who has asked questions", and it will no longer be asked.

2) Count from the seat next to the seat of the student who asked the question last time, and repeat step 1). If counting to the last seat does not reach m, return to the first classmate and continue counting until m, and ask the classmate.

Programming to find the seat number of the last student in the class who was asked the question. Verify: 1) n=40, m=5; 2) n=51, m=7.

Homework (2)

The attributes of the Faculty in the school include: name (Name), job number (EID), level (Glade), salary (Salary), which are not accessible externally. Operations can be performed externally: showFacultyDetail(): Display: all attribute information. IncreaseGlade(int): increase level, increaseSalary(int): increase salary.

Faculty is divided into two categories: Teacher and Official. In addition to the attributes of Faculty, teachers also include their departments (School) and majors (Discipline). Every time a teacher's level increases, the salary increases by Quot1. In addition to the attributes of Faculty, administration also includes Department and Position. For each level of administrative salary increase, the salary increases by Quot2.

There is a class of giants in the school who are both teachers and administrators. Their salaries increase with the increase of their administrative level and teacher title.

Programming implementation:

Huang Taiyan is an administrator. After he arrived at Jiaotong University, his position was increased by one level, and his salary was increased by 3,000 yuan. Show him the information after increasing his salary.

ZhaoHong is a teacher. She changed from an associate professor to a professor. The rank increased by one level and her salary increased by 300 yuan. Displays the information after she added her job title.

WangJiaQiong is a big man with two shoulders. After he returned to Jiaotong University, his title was increased by one level, and his position was increased by one level, which shows the information after his salary increase.

Homework (3)

The social value of a person (Person) mainly depends on its annual income (Salary), which is invisible to the outside world. With the progress of society, a person's salary increases by 1,000 yuan per year (Operator ++). After he marries a wife, the daughter-in-law's annual income is included in his annual income (Operator+). displaySalary() displays its income.

Programming implementation:

A male graduate of Jiaotong University just started working with an annual salary of 8,000 yuan. After working for five years, he married a junior who had worked for three years. This shows his annual income (including his wife’s) two years after marrying his junior.

Homework (4)

Input the four numbers of 10, 20, 30, and 40 from the keyboard and save them in the "d:\source.txt" file. Then, read out these numbers and turn them into 101, 202, 303, 404, and store them in "d:\destination.txt".

Homework (5)

Class Point contains private properties x and y coordinates, and it has an externally callable method: calc(Point &p) to calculate the distance between point P and this, and display it on the display.

Class Circle inherits Point, and adds a new externally inaccessible property radius (radium). It also contains an externally accessible method: calc(Circle &c) calculates the difference between the area of ​​circle c and this, and displays it on the display.

Design the external function func(Point &p1, Point &p2), its function is: p1.calc(p2).

Programming implementation:

Realize two points: p1(3,4), p2(4,5)

Realize two circles: c1 (p1, radium=4), c2(p2, radium=3)

Computes func(p1,p2) and func(c1,c2).

content:

The effect of topic one:

The effect of the second topic:

The effect of topic three:

The effect of topic four:

 The effect of topic five:

source code:

vx: zew1040994588

int main()
{
    //题目1
    topic_1_main();
    //题目2
    //topic_2_main();
    //题目3
    //topic_3_main();
    //题目4
    //topic_4_main();
    //题目5
    //topic_5_main();
}
vx: zew1040994588
    //根据职级-职级-来算工资
    //行政信息
    Official* official1 = new Official("教务处", "教务处主任", "HuangTaiyan", 1, 1000); //堆中分配
    official1->IncreaseGlade(1);//职务级别增加1级,工资增加3000元
    official1->showFacultyDetail();


    //教师信息
    Teacher* teacher1 = new Teacher("土木系","土木施工专业","ZhaoHong",1,1000); //堆中分配
    teacher1->IncreaseGlade(1);//职称增加1级,工资增加300元
    teacher1->showFacultyDetail();

    //大佬信息
    Giant* giant1 = new Giant("教务处", "教务处一号主任", "土木系", "土木施工专业", "WangJiaQiong", 1, 1000);
    giant1->Official::IncreaseGlade(1);//职务增加1级别,工资增加3000元
    //这里调用的问题,看起来互相有独立的空间来存储
    giant1->Teacher::IncreaseGlade(1);//职称增加1级,工资增加300元
    giant1->showFacultyDetail();

Guess you like

Origin blog.csdn.net/Elephantpretty/article/details/131396884