Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kochneva darina #82

Open
wants to merge 24 commits into
base: Kochneva_Darina
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions 11.12_Task1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#include <iostream>
#include <cmath>
#include <string>
#include <windows.h>

using namespace std;

class Student{
private:
string FIO;
int year;
int group;
int age;
string checkFIO(string FIO){ //проверка верности ввода данных
if(FIO == ""){
cout<<"Name isn't correct. Enter the name: ";
cin>>FIO;
}
return FIO;
}
int checkYear(int year){ //проверка верности ввода данных
if((year<1)||(year>4)){
cout<<"Course isn't correct. Enter the course: ";
cin>>year;
}
return year;
}
int checkGroup(int group){ //проверка верности ввода данных
if(group == 0){
cout<<"Group isn't correct. Enter the group: ";
cin>>group;
}
return group;
}
int checkAge(int age){ //проверка верности ввода данных
if((age<17)||(age>60)){
cout<<"Age isn't correct. Enter the age: ";
cin>>age;
}
return age;
}
public:
void show();
void input(string FIO, int year,int group,int age);
};
void Student::show(){
cout << "FIO: " << FIO << "\nYear: " << year << "\nGroup: " << group << "\nAge: " << age << endl; //вывод данных студентов на экран
}
void Student::input(string FIO, int year,int group,int age){
this->FIO = checkFIO(FIO);
this->year = checkYear(year);
this->group = checkGroup(group);
this->age = checkAge(age);
}

int main(){
SetConsoleOutputCP(1251);
Student First;
Student Second;
Student Third;
First.input("Kochneva Darina Alexseevna", 1, 42, 18);
Second.input("Bykov Peter Olegovich", 3, 185, 21);
Third.input("Ivanov Ivan Ivanovich", 4, 42, 24);
First.show();
Second.show();
Third.show();

return 0;
}
91 changes: 91 additions & 0 deletions 11.12_Task2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#include <iostream>
#include <cmath>
#include <fstream>
#include <string>
#include <windows.h>

using namespace std;
class Employee{
private:
string FIO;
int years;
string position;
string homeAdd;
string number;
int hours;
int PriseOfWorkHour;
string checkString(string s){ //проверка верности ввода данных
if(s == ""){
cout<<"It isn't correct. Enter again: ";
cin>>s;
}
return s;
}
int checkInt(int i){ //проверка верности ввода данных
if(i==0){
cout<<"It isn't correct. Enter again: ";
cin>>i;
}
return i;
}
public:
Employee(string FIO, int years, string position, string homeAdd, string number, int hours, int PriseOfWorkHour){ //присваивание проверенных данных
this->FIO = checkString(FIO);
this->years = checkInt(years);
this->position =checkString(position);
this->homeAdd = checkString(homeAdd);
this->number = checkString(number);
this->hours = checkInt(hours);
this->PriseOfWorkHour = checkInt(PriseOfWorkHour);
}
void salary(){ //метод расчёта зарплаты
cout << "Salary of this employee: " << hours * PriseOfWorkHour << endl;
}
void premium(){ //метод расчёта премии
if ((years >= 1) && (years < 3)) {
cout << "Premium of this employee: " << (hours * PriseOfWorkHour * 3)/100 << endl;
} else if ((years >= 3) && (years < 6)) {
cout << "Premium of this employee: " << (hours * PriseOfWorkHour * 5)/100 << endl;
} else if ((years >= 6) && (years <= 9)) {
cout << "Premium of this employee: " << (hours * PriseOfWorkHour * 7)/100 << endl;
} else if (years >= 10) {
cout << "Premium of this employee: " << (hours * PriseOfWorkHour * 13)/100 << endl;
}
}
void showInfo(){ //вывод информации о сотруднике на экран
cout << "FIO: " << FIO << endl;
cout << "Experience: " << years << endl;
cout << "Position: " << position << endl;
cout << "Home adress: " << homeAdd << endl;
cout << "Number: " << number << endl;
cout << "Hours: " << hours << endl;
cout << "The cost of one hour of work: " << PriseOfWorkHour << endl;
cout << endl;
}
void record(){ //метод вывода данных в файл
ofstream file(FIO + ".txt");
file << "FIO: " << FIO << endl;
file << "Experience: " << years << endl;
file << "Position: " << position << endl;
file << "Home adress: " << homeAdd << endl;
file << "Number: " << number << endl;
file << "Hours: " << hours << endl;
file << "The cost of one hour of work: " << PriseOfWorkHour << endl;
file.close();
}
};

int main()
{
Employee First("Xina John Bro", 1, "Delevoper", "Ivanovo, Shubinyh 32", "+71231231312", 100, 500);
Employee Second("", 0, "", "", "", 0, 0);
First.showInfo();
Second.showInfo();
First.salary();
Second.salary();
First.premium();
Second.premium();
First.record();
Second.record();
return 0;
}
176 changes: 176 additions & 0 deletions 11.12_Task3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
//Код взят у Бутусова Александра
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

мне он скоро снится будет)

#include <iostream>
#include <ctime>

using namespace std;

class Massive {
public:
int rows;
int columns;
int **Giga; //двумерный динамический массив
int **TrGiga; //транспонированная матрица (динамическая)
int **DopGiga; //дополнительный массив (двумерный динамический)
//a
Massive(int r, int c){
rows = r;
columns = c;
Giga = new int* [rows]; //создаём динамический массив
for (int i = 0; i <rows; i++){
Giga[i] = new int[columns];
}
for (int i = 0; i < rows; i++){ //заполняем случайными числами
for (int j = 0; j < columns; j++){
Giga[i][j] = rand() % 201 + (-100);
}
}
}
//b
~Massive(){
for (int i = 0; i < rows; i++){ //очищаем ячейки массива
delete[] Giga[i];
}
delete Giga; //удаляем двумерный массив
for (int i = 0; i < columns; i++){ //очищаем ячейки транспонированнай матрицы
delete[] TrGiga[i];
}
delete TrGiga; //удаляем транспонированную матрицу
for (int i = 0; i < rows; i++){ //очищаем ячейки дополнительного двумерного массива
delete[] DopGiga[i];
}
delete DopGiga; //удаляем дополнительный массив

}
//c
void showInfo(){ //вывод двумерного массива на экран
for (int i = 0; i < rows; i++){
for (int j = 0; j < columns; j++){
cout << Giga[i][j] << " ";
}
cout << endl;
}
cout << endl;
}
//d
void transport(){ //транспонируем матрицу
TrGiga = new int * [columns];
for (int i = 0; i < columns; i++){
TrGiga[i] = new int[rows];
}
for (int i = 0; i < rows; i++){
for (int j = 0; j < columns; j++){
TrGiga[i][j] = Giga[j][i];
cout << TrGiga[i][j] << " ";
}
cout << endl;
}
cout << endl;
}
//f
void zero(){
for (int i = 0; i < rows; i++){
for (int j = 0; j < columns; j++){
if (Giga[i][j] < 0){ //заменяем отрицательные значения нулями
Giga[i][j] = 0;
}
}
}
}
//e
void sumMatrix(){
DopGiga = new int * [rows]; //создаём матрицу
for (int i = 0; i < rows; i++){
DopGiga[i] = new int[columns];
}
for (int i = 0; i < rows; i++){ //задаём значения ячеек матрицы
for (int j = 0; j < columns; j++){
DopGiga[i][j] = rand() % 201 + (-100);
cout << DopGiga[i][j] << " "; //выводим матрицу на экран
}
cout << endl;
}
cout << endl;
for (int i = 0; i < rows; i++){
for (int j = 0; j < columns; j++){
DopGiga[i][j] = DopGiga[i][j] + Giga[i][j]; //находим сумму двух матриц
cout << DopGiga[i][j] << " "; //выводим на экран
}
cout << endl;
}
}
};

int main(){
srand(time(NULL));
Massive First(3,3); //берём вкачестве примера массив 3х3
Massive Second (4, 4); //берём вкачестве примера массив 4х4
Massive Third (2, 2); //берём вкачестве примера массив 2х2
First.showInfo();
Second.showInfo();
Second.zero();
Second.showInfo();
First.transport();
Third.showInfo();
Third.sumMatrix();


//1
cout << "Array of odd elements in each row of the array = { ";
int *sumNechet = new int[First.rows];
for (int i = 0; i < First.rows; i++){
int t = 1;
int sum = 0;
for (int j = 0; j < First.columns; j++){
if(t % 2 != 0){ //находим нечётные числа в массиве
sum += First.Giga[i][j]; //складываем нечётные числа в каждой строке массива
}
t++;
}
sumNechet[i] = sum; //вводим результат в одномерный массив по строкам
}
for (int i =0; i < First.rows; i++){
cout << sumNechet[i] << " "; //выводим одномерный массив с ответом
}
cout << "}" << endl;

//2
cout << "Array of maximum elements in each column among the odd values = { ";
int *maxStolbNechet = new int[First.columns];
for (int i = 0; i < First.columns; i++){
int max = -1000;
for (int j = 0; j < First.rows; j++){
if((First.Giga[j][i] % 2 != 0) && First.Giga[j][i] > max){ //находим максимум среди нечётных чисел столбцов массива
max = First.Giga[j][i]; //запоминаем максимум из столбца
}
}
maxStolbNechet[i] = max; //записываем максимумы столбцов в одномерный массив
}
for (int i =0; i < First.columns; i++){
if (maxStolbNechet[i] != -1000){ //проверяем наличие максимума
cout << maxStolbNechet[i] << " "; //выводим массив максимумов
} else {
cout << "Nothing! "; //если максимумы не найдены
}
}
cout << "}" << endl;

//3
cout << "Array of average value in each column = { ";
float *sredStolb = new float[First.columns]; //создаём одномрный массив
for (int i = 0; i < First.columns; i++){
int sred = 0;
for (int j = 0; j < First.rows; j++){
sred += First.Giga[j][i]; //складываем числа столбца
}
sredStolb[i] = sred/First.columns; //находим среднее столбца
}
for (int i =0; i < First.columns; i++){
cout << sredStolb[i] << " "; //выводим массив средних значений по столбцам
}
cout << "}" << endl;

delete sredStolb; //удаляем массив
delete sumNechet; //удаляем массив
delete maxStolbNechet; //удаляем массив
return 0;
}
31 changes: 31 additions & 0 deletions 13.10_Task1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <iostream>
#include <cmath>

using namespace std;

double modul(int x, int y, int z){
double m=(pow((pow(x,2)+pow(y,2)+pow(z,2)), 1/2));
return m;
}

int main(){
int x=1, y=5, z=3, leigth=0;
leigth=modul(x, y, z);
cout<<"1. Leigth of vector = "<<leigth<<endl;
int b;
b=(x/leigth)+(y/leigth)+(z/leigth);
cout<<"2. b = "<<b<<endl;
int x1, y1, z1, scalar;
cout<<"x = "; cin>>x1;
cout<<"y = "; cin>>y1;
cout<<"z = "; cin>>z1;
scalar=x*x1+y*y1+z*z1;
cout<<"3. Scalarnoe proizvedenie = "<<scalar<<endl;
double vector, i, j, k;
i=(y*z1-z*y1);
j=-(x*z1-z*x1);
k=(x*y1-y*x1);
vector=modul(i,j,k);
cout<<"4. Vectornoe proizvedenie = "<<vector<<endl;
return 0;
}
Loading