Skip to content
This repository was archived by the owner on Jul 30, 2023. It is now read-only.

Commit 1232005

Browse files
author
danyathecoder
committed
Lab2
1 parent 4054706 commit 1232005

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3502
-0
lines changed

2-5.docx

47.3 KB
Binary file not shown.

Lab1.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <cmath>
2+
#include <iostream>
3+
4+
using namespace std;
5+
6+
int main(){
7+
double a, b, c;
8+
cin >> a >> b >> c;
9+
cout.precision(2);
10+
if(a < 0){
11+
a = (-1)*a;
12+
b = (-1)*b;
13+
c = (-1)*c;
14+
}
15+
if(a == 0 && b == 0)
16+
return 0;
17+
if(a == 0){
18+
cout << (-1.0)*c/b;
19+
return 0;
20+
}
21+
int D = b*b - 4*a*c;
22+
if(D < 0)
23+
return 0;
24+
if(D == 0)
25+
cout << ((-1)*b)/(2*a);
26+
if(D > 0)
27+
cout << ((-1)*b + sqrt(D)) / (2*a)<<" "<< ((-1)*b - sqrt(D)) / (2*a);
28+
return 0;
29+
}

Lab2/.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lab2/.idea/Lab2.iml

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lab2/.idea/misc.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lab2/.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lab2/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cmake_minimum_required(VERSION 3.17)
2+
project(Lab2)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
6+
add_executable(Lab2 main.cpp Schoolkid.cpp Schoolkid.h Teacher.cpp Teacher.h)

Lab2/Schoolkid.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// Created by danilapoddubny on 11/09/2020.
3+
//
4+
5+
#include "Schoolkid.h"
6+
#include <iostream>
7+
#include <iomanip>
8+
9+
Schoolkid::Schoolkid(const string &new_name, const int &new_id, const int &new_missed) {
10+
id = new_id;
11+
missed = new_missed;
12+
name = new_name;
13+
}
14+
15+
Schoolkid::Schoolkid() {
16+
id = 42;
17+
missed = 0;
18+
name = "John Doe";
19+
}
20+
21+
Schoolkid::~Schoolkid() {
22+
cout << "Goodbye, " << name << "."<< endl;
23+
}
24+
25+
void Schoolkid::changeName(const string &new_name) {
26+
name = new_name;
27+
}
28+
29+
void Schoolkid::changeID(const int &n) {
30+
id = n;
31+
}
32+
33+
void printData(const Schoolkid& obj){
34+
cout << obj.name;
35+
cout << setw(53) << obj.id;
36+
cout << setw(40) << obj.missed << endl;
37+
}

Lab2/Schoolkid.h

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// Created by danilapoddubny on 11/09/2020.
3+
//
4+
5+
#ifndef LAB2_SCHOOLKID_H
6+
#define LAB2_SCHOOLKID_H
7+
8+
#include <string>
9+
using namespace std;
10+
11+
class Schoolkid {
12+
private:
13+
int id;
14+
int missed;
15+
string name;
16+
public:
17+
Schoolkid(const string& new_name, const int& new_id, const int& new_missed);
18+
Schoolkid();
19+
~Schoolkid();
20+
friend void printData(const Schoolkid& obj);
21+
friend class Teacher;
22+
void changeName(const string& new_name);
23+
void changeID(const int& n);
24+
};
25+
26+
void printData(const Schoolkid& obj);
27+
28+
29+
#endif //LAB2_SCHOOLKID_H

Lab2/Teacher.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// Created by danilapoddubny on 11/09/2020.
3+
//
4+
5+
#include "Teacher.h"
6+
#include <iostream>
7+
8+
Teacher::Teacher() {
9+
name = "Maria Ivanovna";
10+
salary = "too low";
11+
}
12+
13+
void Teacher::setMissings(Schoolkid &obj, const int missings) {
14+
obj.missed = missings;
15+
}
16+
17+
void sayHelloToMyLittleFriend(const Teacher& obj){
18+
cout << "https://www.youtube.com/watch?v=AVQ8byG2mY8&ab_channel=Godlike"<< endl <<
19+
"Hi, children. My name is " << obj.name <<
20+
"And my salary is " << obj.salary << " to listen you." << endl;
21+
}

Lab2/Teacher.h

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// Created by danilapoddubny on 11/09/2020.
3+
//
4+
5+
#ifndef LAB2_TEACHER_H
6+
#define LAB2_TEACHER_H
7+
8+
#include "Schoolkid.h"
9+
#include <string>
10+
using namespace std;
11+
12+
13+
class Teacher {
14+
private:
15+
string name;
16+
string salary;
17+
public:
18+
Teacher();
19+
void setMissings(Schoolkid& obj, const int missings);
20+
friend void sayHelloToMyLittleFriend(const Teacher& obj);
21+
};
22+
23+
void sayHelloToMyLittleFriend(const Teacher& obj);
24+
25+
26+
#endif //LAB2_TEACHER_H

0 commit comments

Comments
 (0)