Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file not shown.
9,592 changes: 9,592 additions & 0 deletions SaryninS/lab 1/gtest/gtest-all.cc

Large diffs are not rendered by default.

20,065 changes: 20,065 additions & 0 deletions SaryninS/lab 1/gtest/gtest.h

Large diffs are not rendered by default.

137 changes: 137 additions & 0 deletions SaryninS/lab 1/include/List.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#pragma once
#include "node.h"

template<typename T>
class List
{
protected:
Node<T> *head;
Node<T> *current;
public:
List();// �����������
List(const List<T> &lst);//������ ����������
~List();// ����������

void Clean(); // ������� ��� ������
List<T>& operator=(const List<T>& lst);//�������� ������������
Node<T>* GetCurr() const { return current; } // �������� ��������� �� �������
void InsertAfter(Node<T>* n, T d);// ������� ����� ��������� ��������
void InsertOrdered(T d);//������ � �������������

void GetNext() { current = current->next; } //current �������� �� 1 ������
void Reset() { current = head->next; } // ���������� ��������� �� ������
bool IsEnded() const { return current == head; } //�������� �� ����� �� ������

bool operator==(const List<T>& lst) const;
bool operator!=(const List<T>& lst) const;
};

template <typename T>
List<T>::List()
{
head = new Node<T>;
head->next = head;
current = head->next;
}

template <typename T>
List<T>::List(const List<T>& lst)
{
Node<T>* tmp = lst.head;
head = new Node<T>(tmp->data);
head->next = head;
current = head;
while (tmp->next != lst.head)
{
tmp = tmp->next;
current->next = new Node<T>(tmp->data);
GetNext();
}
current->next = head;

}

template <class T>
List<T>::~List()
{
Clean();
delete head;
}

template <class T>
List<T>& List<T>::operator=(const List<T>& lst)
{
Clean();
Node<T>* tmp = lst.head;
Node<T>* tmp2 = head;
while (tmp->next != lst.head)
{
tmp = tmp->next;
tmp2->next = new Node<T>(tmp->data);
tmp2 = tmp2->next;
}
tmp2->next = head;
current = head->next;
return *this;
}

template <class T>
void List<T>::InsertAfter(Node<T>* n, T d)
{
Node<T>* tmp = n->next;
n->next = new Node<T>(d);
n->next->next = tmp;
}

template <class T>
void List<T>::InsertOrdered(T d)
{
Node<T>* tmp;
current = head;
while ((current->next->data > d) && current->next != head)
{
GetNext();
}
tmp = current->next;
current->next = new Node<T>(d);
current->next->next = tmp;
}

template <class T>
void List<T>::Clean()
{
Node<T>* tmp = head->next;
Node<T>* tmp2;
while (tmp != head)
{
tmp2 = tmp->next;
delete tmp;
tmp = tmp2;
}
head->next = head;
}

template<class T>
bool List<T>::operator==(const List<T>& lst) const
{
bool res = true;
if (this != &lst)
{
Node<T>* tmp1 = head->next;
Node<T>* tmp2 = lst.head->next;
while (tmp1->data == tmp2->data && tmp1 != head && tmp2 != lst.head)
{
tmp1 = tmp1->next;
tmp2 = tmp2->next;
}
if (tmp1 != head || tmp2 != lst.head)
res = false;
}
return res;
}

template<class T>
bool List<T>::operator!=(const List<T>& lst)const
{
return !(*this == lst);
}
Empty file.
16 changes: 16 additions & 0 deletions SaryninS/lab 1/include/monom.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
class Monom
{
public:
double cf;
unsigned int abc;

Monom(double a= 0 , unsigned int b = 0) { cf = a; abc = b;}

Monom& operator=(const Monom& m);
bool operator< (const Monom& m) const;
bool operator> (const Monom& m) const;

bool operator==(const Monom& m) const;
bool operator!=(const Monom& m) const;
};
23 changes: 23 additions & 0 deletions SaryninS/lab 1/include/node.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once
#include <iostream>

template <typename T>

class Node
{
public:
T data;
Node<T>* next;

Node(T d = NULL, Node<T>* l = NULL)
{
data = d;
next = l;
}

bool operator< (const Node<T>& n) const { return (data<n.data); }
bool operator> (const Node<T>& n) const { return (data>n.data); }

bool operator!= (const Node<T>& n) const { return !(*this == n); }
bool operator==(const Node<T>& n) const { return (data == n.data && next == n.next); }
};
32 changes: 32 additions & 0 deletions SaryninS/lab 1/include/polinom.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include <iostream>
#include <string>
#include <algorithm>
#include "monom.h"
#include "List.h"

#define X 120//��� x

using namespace std;

class Polinom
{
private:
List<Monom> list_m;
public:
Polinom(const string Line = "" ); // ����������� �� ������
Polinom(const Monom m) { list_m.InsertAfter(list_m.GetCurr(),m); }// ����������� �������������� ���� �� ������
Polinom(const List<Monom> &p2) { this->list_m = p2; }; // ����������� �������������� ���� �� ������
Polinom(const Polinom& pol) { this->list_m = pol.list_m; }; //����������� �����������

Polinom operator+ (const Polinom&) const;
Polinom operator- (const Polinom& pol) const { return (*this + pol *(-1.0)); }
Polinom operator* (const Polinom& pol) const;
Polinom operator* (const double c) const;

bool operator== (const Polinom& pol) const { return list_m == pol.list_m; }
bool operator!= (const Polinom& pol) const { return list_m != pol.list_m; }

friend ostream& operator<< (ostream& os, const Polinom&);
};
36 changes: 36 additions & 0 deletions SaryninS/lab 1/sample/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "polinom.h"
#include "List.h"

int main()
{
cout << "use x,y,z " << endl << endl;
int f = 1;
string pol1;
string pol2;
Polinom res;
while (f != 0)
{
cout << "enter the first polynomial" << endl;
cin >> pol1;
Polinom A(pol1);
cout << "first polinomial = " << A << endl;
cout << "enter the second polynomial" << endl;
cin >> pol2;
Polinom B(pol2);
cout << "second polinomial = " << B << endl << endl;
res = A + B;
cout << " sum = ";
cout << res << endl;
res = A - B;
cout << " difference = ";
cout << res << endl;
res = A * B;
cout << " multiplication = ";
cout << res << endl;
cout << endl;
cout << "enter 0 for exit and any character to continue " << endl;
cin >> f;
cout << endl;
}
return 0;
}
Empty file.
Binary file not shown.
Binary file not shown.
61 changes: 61 additions & 0 deletions SaryninS/lab 1/sln/polinom/Project1.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project1", "Project1\Project1.vcxproj", "{AF9F51BA-2721-40E4-A44B-4BEB6F405563}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "polinom_lib", "polinom_lib\polinom_lib.vcxproj", "{1809BACB-D2E5-4B45-942E-0CE53EA8C44C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "polinom_sample", "polinom_sample\polinom_sample.vcxproj", "{2B7CA3DD-5436-4412-A20C-405C595DA8E6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "polinom_tests", "polinom_tests\polinom_tests.vcxproj", "{ACA2AFD3-81C1-4897-919A-0F93073FD25B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AF9F51BA-2721-40E4-A44B-4BEB6F405563}.Debug|x64.ActiveCfg = Debug|x64
{AF9F51BA-2721-40E4-A44B-4BEB6F405563}.Debug|x64.Build.0 = Debug|x64
{AF9F51BA-2721-40E4-A44B-4BEB6F405563}.Debug|x86.ActiveCfg = Debug|Win32
{AF9F51BA-2721-40E4-A44B-4BEB6F405563}.Debug|x86.Build.0 = Debug|Win32
{AF9F51BA-2721-40E4-A44B-4BEB6F405563}.Release|x64.ActiveCfg = Release|x64
{AF9F51BA-2721-40E4-A44B-4BEB6F405563}.Release|x64.Build.0 = Release|x64
{AF9F51BA-2721-40E4-A44B-4BEB6F405563}.Release|x86.ActiveCfg = Release|Win32
{AF9F51BA-2721-40E4-A44B-4BEB6F405563}.Release|x86.Build.0 = Release|Win32
{1809BACB-D2E5-4B45-942E-0CE53EA8C44C}.Debug|x64.ActiveCfg = Debug|x64
{1809BACB-D2E5-4B45-942E-0CE53EA8C44C}.Debug|x64.Build.0 = Debug|x64
{1809BACB-D2E5-4B45-942E-0CE53EA8C44C}.Debug|x86.ActiveCfg = Debug|Win32
{1809BACB-D2E5-4B45-942E-0CE53EA8C44C}.Debug|x86.Build.0 = Debug|Win32
{1809BACB-D2E5-4B45-942E-0CE53EA8C44C}.Release|x64.ActiveCfg = Release|x64
{1809BACB-D2E5-4B45-942E-0CE53EA8C44C}.Release|x64.Build.0 = Release|x64
{1809BACB-D2E5-4B45-942E-0CE53EA8C44C}.Release|x86.ActiveCfg = Release|Win32
{1809BACB-D2E5-4B45-942E-0CE53EA8C44C}.Release|x86.Build.0 = Release|Win32
{2B7CA3DD-5436-4412-A20C-405C595DA8E6}.Debug|x64.ActiveCfg = Debug|x64
{2B7CA3DD-5436-4412-A20C-405C595DA8E6}.Debug|x64.Build.0 = Debug|x64
{2B7CA3DD-5436-4412-A20C-405C595DA8E6}.Debug|x86.ActiveCfg = Debug|Win32
{2B7CA3DD-5436-4412-A20C-405C595DA8E6}.Debug|x86.Build.0 = Debug|Win32
{2B7CA3DD-5436-4412-A20C-405C595DA8E6}.Release|x64.ActiveCfg = Release|x64
{2B7CA3DD-5436-4412-A20C-405C595DA8E6}.Release|x64.Build.0 = Release|x64
{2B7CA3DD-5436-4412-A20C-405C595DA8E6}.Release|x86.ActiveCfg = Release|Win32
{2B7CA3DD-5436-4412-A20C-405C595DA8E6}.Release|x86.Build.0 = Release|Win32
{ACA2AFD3-81C1-4897-919A-0F93073FD25B}.Debug|x64.ActiveCfg = Debug|x64
{ACA2AFD3-81C1-4897-919A-0F93073FD25B}.Debug|x64.Build.0 = Debug|x64
{ACA2AFD3-81C1-4897-919A-0F93073FD25B}.Debug|x86.ActiveCfg = Debug|Win32
{ACA2AFD3-81C1-4897-919A-0F93073FD25B}.Debug|x86.Build.0 = Debug|Win32
{ACA2AFD3-81C1-4897-919A-0F93073FD25B}.Release|x64.ActiveCfg = Release|x64
{ACA2AFD3-81C1-4897-919A-0F93073FD25B}.Release|x64.Build.0 = Release|x64
{ACA2AFD3-81C1-4897-919A-0F93073FD25B}.Release|x86.ActiveCfg = Release|Win32
{ACA2AFD3-81C1-4897-919A-0F93073FD25B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F1F622C8-99B4-4AA5-B5EF-7B9918BA85BA}
EndGlobalSection
EndGlobal
Loading