diff --git a/zuenoksg/C_lab/Bitwise/Bitwise/Bitwise.cpp b/zuenoksg/C_lab/Bitwise/Bitwise/Bitwise.cpp new file mode 100644 index 0000000..c44583b --- /dev/null +++ b/zuenoksg/C_lab/Bitwise/Bitwise/Bitwise.cpp @@ -0,0 +1,84 @@ +// Bitwise.cpp: . +// + +#include +#include +#include +#include + +enum Style { + // (B bold), (I italic), (U underline) + NONE = 0, // 0000 + B = 1, // 0001 + I = 1 << 1, // 0010 + U = 1 << 2, // 0100 + ALL = B | I | U // 0111 +}; + +enum StlPrgf { + bold = 0x100, // 0001 0000 0000 + italic = 0x100 << 1, // 0010 0000 0000 + underline = 0x100 << 2, // 0100 0000 0000 + all = bold | italic | underline, // 0111 0000 0000 + + Left = 0x800, // 0000 1000 0000 0000 + Center = 0x800 << 1, // 0001 0000 0000 0000 + Right = 0x800 << 2, // 0010 0000 0000 0000 + Justify = 0x800 << 3, // 0100 0000 0000 0000 +}; + +void PrintHtml(char const*, int); +void SetTextParagraphDisplay(uint32_t); + +int main() { + setlocale(LC_ALL, "Russian"); + char const* simple_string; + + simple_string = ""; + PrintHtml(simple_string, ALL); + printf("\n"); + + simple_string = "Hello, World"; + PrintHtml(simple_string, U | I); + printf("\n"); + + SetTextParagraphDisplay(bold | italic | underline | Left | 100); + printf("\n"); + + return 0; +} + +void PrintHtml(char const* string, int style) { + char *out_B, *out_I, *out_U, + *out__B, *out__I, *out__U; + + out_B = (style&B) ? "" : ""; + out_I = (style&I) ? "" : ""; + out_U = (style&U) ? "" : ""; + out__B = (style&B) ? "" : ""; + out__I = (style&I) ? "" : ""; + out__U = (style&U) ? "" : ""; + + printf("%s%s%s%s%s%s%s", out_B, out_I, out_U, string, out__U, out__I, out__B); +}; + +void SetTextParagraphDisplay(uint32_t flags) { + char *out__b, *out__i, *out__u, + *out__L, *out__C, *out__R, *out__J; + + printf("\nText paragraph display settings: %d\n", flags); + + out__b = (flags&bold) ? "bold" : ""; + out__i = (flags&italic) ? "italic" : ""; + out__u = (flags&underline) ? "underline" : ""; + out__L = (flags&Left) ? "Left" : ""; + out__C = (flags&Center) ? "Center" : ""; + out__R = (flags&Right) ? "Right" : ""; + out__J = (flags&Justify) ? "Justify" : ""; + + if (flags & 0xFF00) { + printf("\nStyle: %s %s %s", out__b, out__i, out__u); + printf("\nHorAlign: %s %s %s %s", out__L, out__C, out__R, out__J); + } + printf("\nSize: %d", flags & 0xFF); +}; \ No newline at end of file diff --git a/zuenoksg/HomeWork1/HomeWork1.sln b/zuenoksg/HomeWork1/HomeWork1.sln new file mode 100644 index 0000000..b46adc6 --- /dev/null +++ b/zuenoksg/HomeWork1/HomeWork1.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26403.7 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HomeWork1", "HomeWork1\HomeWork1.vcxproj", "{DF16475D-7E73-444D-8C96-6A9B352423C7}" +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 + {DF16475D-7E73-444D-8C96-6A9B352423C7}.Debug|x64.ActiveCfg = Debug|x64 + {DF16475D-7E73-444D-8C96-6A9B352423C7}.Debug|x64.Build.0 = Debug|x64 + {DF16475D-7E73-444D-8C96-6A9B352423C7}.Debug|x86.ActiveCfg = Debug|Win32 + {DF16475D-7E73-444D-8C96-6A9B352423C7}.Debug|x86.Build.0 = Debug|Win32 + {DF16475D-7E73-444D-8C96-6A9B352423C7}.Release|x64.ActiveCfg = Release|x64 + {DF16475D-7E73-444D-8C96-6A9B352423C7}.Release|x64.Build.0 = Release|x64 + {DF16475D-7E73-444D-8C96-6A9B352423C7}.Release|x86.ActiveCfg = Release|Win32 + {DF16475D-7E73-444D-8C96-6A9B352423C7}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/zuenoksg/HomeWork1/HomeWork1/HomeWork1.cpp b/zuenoksg/HomeWork1/HomeWork1/HomeWork1.cpp new file mode 100644 index 0000000..3d71ac0 --- /dev/null +++ b/zuenoksg/HomeWork1/HomeWork1/HomeWork1.cpp @@ -0,0 +1,376 @@ +// HomeWork1.cpp: . +// : . +// , .42016 + +#include "stdafx.h" +using namespace std; + +const size_t cName = 15, cNumb = 7; +size_t M = 6, N = 7; + +void arrPrn(int **mass, size_t _x, size_t _y); +void arrInit(int **mass, size_t _x, size_t _y); +int delCol(int **mass, size_t _x, size_t &_y, size_t _z); +int addCol(int **mass, size_t _x, size_t &_y, size_t _z); +int moveRowCol(int **mass, size_t _x, size_t _y, int stepRow, int stepCol); +int **transp(int **mass, int M, int N); + +void phonebook(void); +void(*options[]) (int &exitcode, char **masP[], char **pName, + char **pNumber, size_t &nSize, size_t &nRec); +int menu(void); +void set_rand(char **[], size_t, size_t); +void out(char **[], size_t); +void get_number(char(&name)[cName], char(&number)[cNumb]); + +void read(int &, char **masP[], char **, char **, size_t &, size_t &), +enter(int &, char **masP[], char **, char **, size_t &, size_t &), +del(int &, char **masP[], char **, char **, size_t &, size_t &), +edit(int &, char **masP[], char **, char **, size_t &, size_t &), +fname(int &, char **masP[], char **, char **, size_t &, size_t &), +fnumb(int &, char **masP[], char **, char **, size_t &, size_t &), +quit(int &, char **masP[], char **, char **, size_t &, size_t &); + +int main() { + /*int **mass = new int*[M]; + for (int **ptr = mass, **end = mass + M; ptr != end; ptr++) *ptr = new int[N]; + arrInit(mass, M, N); + arrPrn(mass, M, N); + size_t _z = 1;*/ + + //****Task 1: + /*cout << "Which column you want to delete?\nEnter the column number... "; + cin >> _z; + delCol(mass, M, N, _z); + arrPrn(mass, M, N);*/ + + //****Task 2: + /*cout << "In which position do you want to add a column?\nEnter the column number... "; + cin >> _z; + addCol(mass, M, N, _z); + arrPrn(mass, M, N);*/ + + //****Task 3: + /*for (int dirc = 1, i = 0; i < M; i++, dirc *= -1) { + for (size_t j = 0; j < N; j++) { + moveRowCol(mass, M, N, dirc, dirc); + arrPrn(mass, M, N); + } + }*/ + + //****Task 4: + //arrPrn(transp(mass, M, N), N, M); + + //****Task 1: + phonebook(); + + /*for (int **ptr = mass, **end = mass + M; ptr < end; ptr++) delete[] * ptr; + delete[] mass;*/ + + //system("pause"); + return 0; +} + +void arrPrn(int **mass, size_t _x, size_t _y) { + for (int **ptr = mass, **end = mass + _x; ptr != end; ptr++) { + for (int *ptr_y = *ptr, *end = *ptr + _y; ptr_y != end; ptr_y++) { + printf("%4d", *ptr_y); + } + printf("\n"); + } + printf("\n"); +} + +void arrInit(int **mass, size_t _x, size_t _y) { + int i = 1; + for (int **ptr = mass, **end = mass + _x; ptr != end; ptr++) + for (int *ptr_y = *ptr, *end = *ptr + _y; ptr_y != end; ptr_y++) + *ptr_y = i++; +} + +int delCol(int **mass, size_t _x, size_t &_y, size_t nDelCol) { + if (!(nDelCol > 0 && nDelCol <= _y)) { + printf("The column number values are out of range\n" + "Deletion is canceled.\n\n"); + return 1; + } + else { + printf("Delete column number %d\n\n", nDelCol); + _y--; + for (size_t i = 0; i < _x; i++) { + int *temp = new int[_y]; + for (size_t j = 0, k = 0; j < _y + 1; j++) + if (j != nDelCol - 1) + temp[k++] = mass[i][j]; + delete[] mass[i]; + mass[i] = temp; + } + return 0; + } +} + +int addCol(int **mass, size_t _x, size_t &_y, size_t nAddCol) { + if (!(nAddCol > 0 && nAddCol <= _y + 1)) { + printf("The column number values are out of range\n" + "Addition to this position is not possible.\n\n"); + return 1; + } + else { + printf("Add column number %d\n\n", nAddCol); + nAddCol--; + _y++; + char *ptr = new char[_y * sizeof(**mass)]; + for (size_t i = 0; i < _x; i++) { + int *temp = new int[_y]; + for (int **ptr_x = mass, **end = mass + i + 1; ptr_x != end; ptr_x++) { + memcpy(temp, *ptr_x, nAddCol * sizeof(**ptr_x)); + memcpy(temp + nAddCol + 1, *ptr_x + nAddCol, + (_y - nAddCol - 1) * sizeof(**ptr_x)); + } + delete[] mass[i]; + mass[i] = temp; + mass[i][nAddCol] = 0; + } + delete[] ptr; + return 0; + } +} + +int moveRowCol(int **mass, size_t _x, size_t _y, int stepRow, int stepCol) { + if (stepRow < 0) { + moveRowCol(mass, _x, _y, _x + stepRow, 0); + return 0; + } { + char *ptr = new char[stepRow * sizeof(*mass)]; + memcpy(ptr, mass, stepRow * sizeof(*mass)); + memcpy(mass, mass + stepRow, (_x - stepRow) * sizeof(*mass)); + memcpy(mass + _x - stepRow, ptr, stepRow * sizeof(*mass)); + delete[] ptr; + } + if (stepCol < 0) { + moveRowCol(mass, _x, _y, 0, _y + stepCol); + return 0; + } { + char *ptr = new char[stepCol * sizeof(**mass)]; + for (int **ptr_x = mass, **end = mass + _x; ptr_x != end; ptr_x++) { + memcpy(ptr, *ptr_x, stepCol * sizeof(**ptr_x)); + memcpy(*ptr_x, *ptr_x + stepCol, (_y - stepCol) * sizeof(**ptr_x)); + memcpy(*ptr_x + _y - stepCol, ptr, stepCol * sizeof(**ptr_x)); + } + delete[] ptr; + } + return 0; +} + +int **transp(int **mass, int M, int N) { + int **newMass = new int *[N]; + if (newMass == NULL) { + cout << "This matrix has no determinant\n"; + exit(1); + } + for (int i = 0; i < N; i++) { + newMass[i] = new int[M]; + if (newMass[i] == NULL) { + cout << "This matrix has no determinant\n"; + exit(1); + } + } + for (int i = 0; i < M; i++) + for (int j = 0; j < N; j++) + newMass[j][i] = mass[i][j]; + return newMass; +} + +void phonebook(void) { + size_t nRec = 10; + size_t nSize = nRec; + + char **pName = new char*[nRec]; + char **pNumb = new char*[nRec]; + + for (size_t i = 0; i < nRec; i++) { + pName[i] = new char[nSize]; + pNumb[i] = new char[nSize]; + } + + char **masP[] = { pName, pNumb }; + + set_rand(masP, nSize, nRec); + out(masP, nRec); + + int exitcode = 1; + for (; exitcode;) { + (*options[menu()])(exitcode, masP, pName, pNumb, nSize, nRec); + } + + for (char **ptr = pName, **end = pName + sizeof(pName); ptr < end; ptr++) delete[] * ptr; + delete[] pName; + for (char **ptr = pNumb, **end = pNumb + sizeof(pNumb); ptr < end; ptr++) delete[] * ptr; + delete[] pNumb; +} + +void get_number(char(&name)[cName], char(&number)[cNumb]) { + int radix = 10; + cout << "\nEnter name : "; + cin >> name; + cout << name << endl; + cout << "Enter telephone number : "; + int t; + cin >> t; + _itoa_s(t, number, cNumb, radix); +} + +void set_rand(char **p[], size_t nSize, size_t nRec) { + const char buff = 15; + int radix = 10; + char tmp[buff]; + char *xName[buff] = { "Ivanov","Petrov", + "Sidorov","Zaitcev","Vasilev","Kuzmin", + "Stepanov", "Novak","Gruzdev","Lesnov" }; + for (size_t j = 0, i = 0; i < nRec; i++) { + for (j = 0; xName[i][j]; j++) { + p[0][i][j] = xName[i][j]; + } + p[0][i][j] = '\0'; + _itoa_s(((rand() % 1000000) * 123 + 1000000), tmp, nSize, radix); + for (j = 0; j < strlen(tmp); j++) { + p[1][i][j] = tmp[j]; + } + p[1][i][j] = '\0'; + } +} + +void out(char **p[], size_t nRec) { + cout << "Total " << nRec << " records." << endl; + cout << "Name:\tTel number:\n"; + for (size_t i = 0; i < nRec; i++) { + cout.width(10); + cout << p[0][i] << " "; + cout.width(7); + cout << p[1][i] << endl; + } +} + +int find(char **p[], const size_t nRec) { + /*char *nam = *p[0]; + char *numb = *p[1]; + char name, number; + get_number(name, number); + for (int i = 0; i < nRec; i++) + if (*(nam + i) == name) + if (*(numb + i) == number) + return i;*/ + return -1; +} +// +//void get_number(char& name, char& number) { +// cout << " : "; +// cin >> name; +// cout << " : "; +// cin >> number; +// cout << "\numb"; +//} + +void(*options[]) (int &exitcode, char **masP[], char **pName, + char **pNumber, size_t &nSize, size_t &nRec) = { + read, + enter, + del, + edit, + fname, + fnumb, + quit +}; + +int menu(void) { + printf("\n\n******************\n"); + char ch = 1; + do { + printf("1. Read\n"); + printf("2. Enter\n"); + printf("3. Delete\n"); + printf("4. Edit\n"); + printf("5. Find by name\n"); + printf("6. Find by number\n"); + printf("7. Quit\n\n"); + printf("Select a number: "); + ch = _getch(); + printf("\n\n"); + } while (!strchr("1234567", ch)); + return ch - 49; +} + +void read(int &exitcode, char **masP[], char **pName, + char **pNumber, size_t &nSize, size_t &nRec) { + printf("In read.\n"); + out(masP, nRec); +} + +void enter(int &exitcode, char **masP[], char **pName, + char **pNumber, size_t &nSize, size_t &nRec) { + printf("In enter.\n\n"); + //char *nam = *masP[0]; + //char *numb = *masP[1]; + char **name_add = new char*[++nRec]; + char **number_add = new char*[nRec]; + char name[cName], number[cNumb]; + get_number(name, number); + for (size_t i = 0; i < nRec; i++) { + if (i == nRec - 1) { + *(name_add + i) = name; + *(number_add + i) = number; + } + else { + *(name_add + i) = *(masP[0] + i); + *(number_add + i) = *(masP[1] + i); + } + } + + for (char **ptr = pName, **end = pName + nRec; ptr < end; ptr++) + delete[] * ptr; + + for (char **ptr = pName, **end = pName + nRec; ptr < end; ptr++) { + //*ptr = *name_add++; + cout << *ptr << endl; + } + + /*for (char **ptr = pNumber, **end = pNumber + sizeof(pNumber)+1; ptr < end; ptr++) + delete[] * ptr;*/ + + /*masP[0] = name_add; + masP[1] = number_add; + out(masP, nRec);*/ + + // + //for (char **ptr = pNumber, **end = pNumber + sizeof(pNumber); ptr < end; ptr++) + // delete[] * ptr; + //delete[] pNumber; + + system("pause"); +} + +void del(int &exitcode, char **masP[], char **pName, + char **pNumber, size_t &nSize, size_t &nRec) { + printf("In del."); +} + +void edit(int &exitcode, char **masP[], char **pName, + char **pNumber, size_t &nSize, size_t &nRec) { + printf("In edit."); +} + +void fname(int &exitcode, char **masP[], char **pName, + char **pNumber, size_t &nSize, size_t &nRec) { + printf("Find by name."); +} + +void fnumb(int &exitcode, char **masP[], char **pName, + char **pNumber, size_t &nSize, size_t &nRec) { + printf("Find by number."); +} + +void quit(int &exitcode, char **masP[], char **pName, + char **pNumber, size_t &nSize, size_t &nRec) { + printf("In quit.\n\n"); + exitcode = 0; +} \ No newline at end of file diff --git a/zuenoksg/HomeWork1/HomeWork1/HomeWork1.vcxproj b/zuenoksg/HomeWork1/HomeWork1/HomeWork1.vcxproj new file mode 100644 index 0000000..6e4af50 --- /dev/null +++ b/zuenoksg/HomeWork1/HomeWork1/HomeWork1.vcxproj @@ -0,0 +1,155 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {DF16475D-7E73-444D-8C96-6A9B352423C7} + Win32Proj + HomeWork1 + 10.0.15063.0 + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + + + + + + + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/zuenoksg/HomeWork1/HomeWork1/HomeWork1.vcxproj.filters b/zuenoksg/HomeWork1/HomeWork1/HomeWork1.vcxproj.filters new file mode 100644 index 0000000..480303f --- /dev/null +++ b/zuenoksg/HomeWork1/HomeWork1/HomeWork1.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Заголовочные файлы + + + Заголовочные файлы + + + + + Файлы исходного кода + + + Файлы исходного кода + + + \ No newline at end of file diff --git a/zuenoksg/HomeWork1/HomeWork1/ReadMe.txt b/zuenoksg/HomeWork1/HomeWork1/ReadMe.txt new file mode 100644 index 0000000..b5e01e2 --- /dev/null +++ b/zuenoksg/HomeWork1/HomeWork1/ReadMe.txt @@ -0,0 +1,30 @@ +======================================================================== + КОНСОЛЬНОЕ ПРИЛОЖЕНИЕ. Обзор проекта HomeWork1 +======================================================================== + +Это приложение HomeWork1 создано автоматически с помощью мастера приложений. + +В этом файле представлена сводка содержимого всех файлов, входящих в состав приложения HomeWork1. + + +HomeWork1.vcxproj + Это основной файл проекта VC++, создаваемый с помощью мастера приложений. Он содержит данные о версии языка Visual C++, использованной для создания файла, а также сведения о платформах, конфигурациях и функциях проекта, выбранных с помощью мастера приложений. + +HomeWork1.vcxproj.filters + Это файл фильтров для проектов VC++, созданный с помощью мастера приложений. Он содержит сведения о сопоставлениях между файлами в вашем проекте и фильтрами. Эти сопоставления используются в среде IDE для группировки файлов с одинаковыми расширениями в одном узле (например CPP-файлы сопоставляются с фильтром "Исходные файлы"). + +HomeWork1.cpp + Это основной исходный файл приложения. + +///////////////////////////////////////////////////////////////////////////// +Другие стандартные файлы: + +StdAfx.h, StdAfx.cpp + Эти файлы используются для построения файла предкомпилированного заголовка (PCH) с именем HomeWork1.pch и файла предкомпилированных типов с именем StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// +Прочие примечания. + +С помощью комментариев «TODO:» в мастере приложений обозначаются фрагменты исходного кода, которые необходимо дополнить или изменить. + +///////////////////////////////////////////////////////////////////////////// diff --git a/zuenoksg/HomeWork1/HomeWork1/stdafx.cpp b/zuenoksg/HomeWork1/HomeWork1/stdafx.cpp new file mode 100644 index 0000000..8de3f4e --- /dev/null +++ b/zuenoksg/HomeWork1/HomeWork1/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp: , +// HomeWork1.pch +// stdafx.obj + +#include "stdafx.h" + +// TODO: STDAFX.H +// , diff --git a/zuenoksg/HomeWork1/HomeWork1/stdafx.h b/zuenoksg/HomeWork1/HomeWork1/stdafx.h new file mode 100644 index 0000000..22ad6ce --- /dev/null +++ b/zuenoksg/HomeWork1/HomeWork1/stdafx.h @@ -0,0 +1,18 @@ +// stdafx.h: +// , , +// +// + +#pragma once + +#include "targetver.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/zuenoksg/HomeWork1/HomeWork1/targetver.h b/zuenoksg/HomeWork1/HomeWork1/targetver.h new file mode 100644 index 0000000..fd33074 --- /dev/null +++ b/zuenoksg/HomeWork1/HomeWork1/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h Windows. + +// Windows, WinSDKVer.h +// _WIN32_WINNT SDKDDKVer.h. + +#include diff --git a/zuenoksg/Structures_start/Structures_start.sln b/zuenoksg/Structures_start/Structures_start.sln new file mode 100644 index 0000000..b5abb1e --- /dev/null +++ b/zuenoksg/Structures_start/Structures_start.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Structures_start", "Structures_start\Structures_start.vcxproj", "{83FDE0F8-E7D9-409F-820D-C27649227EDC}" +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 + {83FDE0F8-E7D9-409F-820D-C27649227EDC}.Debug|x64.ActiveCfg = Debug|x64 + {83FDE0F8-E7D9-409F-820D-C27649227EDC}.Debug|x64.Build.0 = Debug|x64 + {83FDE0F8-E7D9-409F-820D-C27649227EDC}.Debug|x86.ActiveCfg = Debug|Win32 + {83FDE0F8-E7D9-409F-820D-C27649227EDC}.Debug|x86.Build.0 = Debug|Win32 + {83FDE0F8-E7D9-409F-820D-C27649227EDC}.Release|x64.ActiveCfg = Release|x64 + {83FDE0F8-E7D9-409F-820D-C27649227EDC}.Release|x64.Build.0 = Release|x64 + {83FDE0F8-E7D9-409F-820D-C27649227EDC}.Release|x86.ActiveCfg = Release|Win32 + {83FDE0F8-E7D9-409F-820D-C27649227EDC}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/zuenoksg/Structures_start/Structures_start/ReadMe.txt b/zuenoksg/Structures_start/Structures_start/ReadMe.txt new file mode 100644 index 0000000..93ff3fa --- /dev/null +++ b/zuenoksg/Structures_start/Structures_start/ReadMe.txt @@ -0,0 +1,30 @@ +======================================================================== + КОНСОЛЬНОЕ ПРИЛОЖЕНИЕ. Обзор проекта Structures_start +======================================================================== + +Это приложение Structures_start создано автоматически с помощью мастера приложений. + +В этом файле представлена сводка содержимого всех файлов, входящих в состав приложения Structures_start. + + +Structures_start.vcxproj + Это основной файл проекта VC++, создаваемый с помощью мастера приложений. Он содержит данные о версии языка Visual C++, использованной для создания файла, а также сведения о платформах, конфигурациях и функциях проекта, выбранных с помощью мастера приложений. + +Structures_start.vcxproj.filters + Это файл фильтров для проектов VC++, созданный с помощью мастера приложений. Он содержит сведения о сопоставлениях между файлами в вашем проекте и фильтрами. Эти сопоставления используются в среде IDE для группировки файлов с одинаковыми расширениями в одном узле (например CPP-файлы сопоставляются с фильтром "Исходные файлы"). + +Structures_start.cpp + Это основной исходный файл приложения. + +///////////////////////////////////////////////////////////////////////////// +Другие стандартные файлы: + +StdAfx.h, StdAfx.cpp + Эти файлы используются для построения файла предкомпилированного заголовка (PCH) с именем Structures_start.pch и файла предкомпилированных типов с именем StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// +Прочие примечания. + +С помощью комментариев «TODO:» в мастере приложений обозначаются фрагменты исходного кода, которые необходимо дополнить или изменить. + +///////////////////////////////////////////////////////////////////////////// diff --git a/zuenoksg/Structures_start/Structures_start/Structures_start.cpp b/zuenoksg/Structures_start/Structures_start/Structures_start.cpp new file mode 100644 index 0000000..f850640 --- /dev/null +++ b/zuenoksg/Structures_start/Structures_start/Structures_start.cpp @@ -0,0 +1,182 @@ +// Structures_start.cpp: определяет точку входа для консольного приложения. +// Тема: Структуры. +// Сергёй Зуёнок, гр.Б42016 + +#include "stdafx.h" + +struct Student { + char firstName[20]; + char lastName[20]; + float avrgMark; +}; + +typedef int(*TwoStudentsCompareFunc) (const struct Student*, const struct Student*); +typedef bool(*StudentCompareFunc) (const struct Student*); + +struct Student* inputData(int n); +void PrintForm(Student**students, int count); + +void PrintStudent(struct Student* students); + +void FreeMem(Student* arr[], int length); + +int CmpStdsFName(const struct Student* studentOne, const struct Student* studentTwo); +int CmpStdsLName(const struct Student* studentOne, const struct Student* studentTwo); +int CmpStdsAvrMark(const struct Student* studentOne, const struct Student* studentTwo); + +void StdsTwoCmp(Student**students); +void CmpStds(Student**students); + +bool CmpFName(const struct Student* student); +bool CmpLName(const struct Student* student); +bool CmpEvltn(const struct Student* student); + +void Sort(struct Student** students, int count, TwoStudentsCompareFunc compare); +Student* Find(Student** students, int count, StudentCompareFunc compare); +int Countif(Student** students, int count, StudentCompareFunc compare); + +int main() { + int const count = 3; + struct Student *students[count]; + for (int i = 0; i < count; i++) *(students + i) = inputData(i); + + PrintForm(students, count); + StdsTwoCmp(students); + CmpStds(students); + + std::cout << "Sort by First Name:\n"; + Sort(students, count, CmpStdsFName); + PrintForm(students, count); + + std::cout << "Sort by Last Name:\n"; + Sort(students, count, CmpStdsLName); + PrintForm(students, count); + + std::cout << "Sort by average mark:\n"; + Sort(students, count, CmpStdsAvrMark); + PrintForm(students, count); + + std::printf("Search for an average mark of more than 6:\n"); + PrintStudent(Find(students, count, CmpEvltn)); + + std::cout << "Quantity of First Names (starting with \"I\"): "; + std::cout << Countif(students, count, CmpFName) << std::endl; + std::cout << "and of Last Names (starting with \"I\"): "; + std::cout << Countif(students, count, CmpLName) << std::endl; + std::cout << "Quantity of students with average mark more then 6.0: "; + std::cout << Countif(students, count, CmpEvltn) << std::endl; + + FreeMem(students, count); + return 0; +} + +struct Student* inputData(int count) { + struct Student *group = (struct Student*) malloc(sizeof(struct Student)); + std::cout << "Student\'s First Name (code " << count << "): "; + std::cin >> group->firstName; + std::cout << "Student\'s Last Name (code " << count << "): "; + std::cin >> group->lastName; + std::cout << "Student\'s average mark (code " << count << "): "; + while (group->avrgMark < 0 || group->avrgMark > 10) { + std::cin >> group->avrgMark; + } + return group; +} + +void PrintStudent(struct Student* students) { + std::cout << "First Name: " << students->firstName << ", Last Name: " + << students->lastName << "; average mark: " << students->avrgMark << "\n"; +} + +void PrintForm(Student**students, int count) { + for (int i = 0; i < count; i++) + std::cout << "First Name: " << students[i]->firstName << ", Last Name: " + << students[i]->lastName << "; average mark: " << students[i]->avrgMark << "\n"; +} + +void FreeMem(Student* arr[], int length) { + for (int i = 0; i < length; i++) delete *(arr + i); +} + +int CmpStdsFName(const struct Student* studentOne, const struct Student* studentTwo) { + return strcmp(studentOne->firstName, studentTwo->firstName); +} +int CmpStdsLName(const struct Student* studentOne, const struct Student* studentTwo) { + return strcmp(studentOne->lastName, studentTwo->lastName); +} +int CmpStdsAvrMark(const struct Student* studentOne, const struct Student* studentTwo) { + if (studentOne->avrgMark == studentTwo->avrgMark) return 0; + else if (studentOne->avrgMark > studentTwo->avrgMark) return 1; + else return -1; +} +void StdsTwoCmp(Student**students) { + int one, two, is_select = 0; + std::cout << "Enter comparison criterion:" << + " 1 - First Name, 2 - Last Name, 3 - Average mark, 4 - Quit\n\n"; + while (is_select > 4 || is_select < 1) std::cin >> is_select; + if (is_select == 4) return; + std::cout << "Enter student codes for comparison:\n"; + std::cin >> one >> two; + if (is_select == 1) std::cout << CmpStdsFName(students[one], students[two]) << std::endl; + if (is_select == 2) std::cout << CmpStdsLName(students[one], students[two]) << std::endl; + if (is_select == 3) std::cout << CmpStdsAvrMark(students[one], students[two]) << std::endl; +} + +void CmpStds(Student**students) { + int numb, refer = 0; + std::cout.setf(std::ios::boolalpha); + std::cout << "The evaluation criteria for comparison:\n" << + " 1 - First Name, 2 - Last Name, 3 - Average mark, 4 - Quit\n"; + while (refer > 4 || refer < 1) std::cin >> refer; + if (refer == 4) return; + std::cout << " Student\'s code ?\n"; + std::cin >> numb; + if (refer == 1) std::cout << CmpFName(students[numb]) << std::endl; + if (refer == 2) std::cout << CmpLName(students[numb]) << std::endl; + if (refer == 3) std::cout << CmpEvltn(students[numb]) << std::endl; + std::cout.unsetf(std::ios::boolalpha); +} + +bool CmpFName(const struct Student* student) { + return (student->firstName[0] == 'I'); +} + +bool CmpLName(const struct Student* student) { + return (student->lastName[0] == 'I'); +} + +bool CmpEvltn(const struct Student* student) { + return (student->avrgMark >= 6.0); +} + +void Sort(struct Student** students, int count, TwoStudentsCompareFunc compare) { + struct Student *temp; + for (int j = 1; j < count; ++j) { + for (int i = 0; i < count - j; ++i) { + if (compare(*(students + i), *(students + i + 1))) { + temp = *(students + i); + *(students + i) = *(students + i + 1); + *(students + i + 1) = temp; + } + } + } +} + +Student* Find(Student** students, int count, StudentCompareFunc compare) { + for (int i = 0; i < count; i++) + if ((*compare)(*(students + i))) + return *(students + i); + std::cout << "Search this criterion no results...\n" << + "The default result is returned.\n"; + return *students; +} + +int Countif(Student** students, int count, StudentCompareFunc compare) { + int result = 0; + for (int i = 0; i < count; ++i) { + if (compare(*(students + i))) { + result++; + } + } + return result; +} \ No newline at end of file diff --git a/zuenoksg/Structures_start/Structures_start/Structures_start.vcxproj b/zuenoksg/Structures_start/Structures_start/Structures_start.vcxproj new file mode 100644 index 0000000..f45084e --- /dev/null +++ b/zuenoksg/Structures_start/Structures_start/Structures_start.vcxproj @@ -0,0 +1,155 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {83FDE0F8-E7D9-409F-820D-C27649227EDC} + Win32Proj + Structures_start + 10.0.15063.0 + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + + + + + + + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/zuenoksg/Structures_start/Structures_start/Structures_start.vcxproj.filters b/zuenoksg/Structures_start/Structures_start/Structures_start.vcxproj.filters new file mode 100644 index 0000000..1033e10 --- /dev/null +++ b/zuenoksg/Structures_start/Structures_start/Structures_start.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Заголовочные файлы + + + Заголовочные файлы + + + + + Файлы исходного кода + + + Файлы исходного кода + + + \ No newline at end of file diff --git a/zuenoksg/Structures_start/Structures_start/stdafx.cpp b/zuenoksg/Structures_start/Structures_start/stdafx.cpp new file mode 100644 index 0000000..0dc9de1 --- /dev/null +++ b/zuenoksg/Structures_start/Structures_start/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp: , +// Structures_start.pch +// stdafx.obj + +#include "stdafx.h" + +// TODO: STDAFX.H +// , diff --git a/zuenoksg/Structures_start/Structures_start/stdafx.h b/zuenoksg/Structures_start/Structures_start/stdafx.h new file mode 100644 index 0000000..49fd434 --- /dev/null +++ b/zuenoksg/Structures_start/Structures_start/stdafx.h @@ -0,0 +1,18 @@ +// stdafx.h: +// , , +// +// + +#pragma once + +#include "targetver.h" + +#include +#include + +#include +#include +#include +#include + +// TODO: , diff --git a/zuenoksg/Structures_start/Structures_start/targetver.h b/zuenoksg/Structures_start/Structures_start/targetver.h new file mode 100644 index 0000000..fd33074 --- /dev/null +++ b/zuenoksg/Structures_start/Structures_start/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h Windows. + +// Windows, WinSDKVer.h +// _WIN32_WINNT SDKDDKVer.h. + +#include diff --git a/zuenoksg/Structures_start/new 1.txt b/zuenoksg/Structures_start/new 1.txt new file mode 100644 index 0000000..4c850e1 --- /dev/null +++ b/zuenoksg/Structures_start/new 1.txt @@ -0,0 +1 @@ +std::cout << "Eiee?anoai eiai aieuoa \"n\" " << std::endl; \ No newline at end of file diff --git a/zuenoksg/Structures_start/new_struct.txt b/zuenoksg/Structures_start/new_struct.txt new file mode 100644 index 0000000..8124951 --- /dev/null +++ b/zuenoksg/Structures_start/new_struct.txt @@ -0,0 +1,191 @@ +#include "stdafx.h" +#include +#include +#include +#include + +struct Student +{ + char name[20]; + char l_name[20]; + float a_score; +}; + +typedef int (*CompareTwoStudentsFunc)(const struct Student*, const struct Student*); +typedef bool(*StudentCompareFunc) (const struct Student*); + +struct Student* inputData(int n); +void FreeMem(Student* g[], int n); +void printGroup(Student**group, int count); +int CompareStudentsByName(const struct Student* student1, const struct Student* student2); +int CompareStudentsByl_name(const struct Student* student1, const struct Student* student2); +int CompareStudentsBya_score(const struct Student* student1, const struct Student* student2); +void StudentsTwoCompareFunc(Student**group); +void FuncCompareStudent(Student**group); +bool StudentCompareName(const struct Student* student); +bool StudentCompareLname(const struct Student* student); +bool StudentCompareAscore(const struct Student* student); + +void Sort(struct Student** students, int n, CompareTwoStudentsFunc compare); +int CountIf(Student** students, int n, StudentCompareFunc compare); + +int main() +{ + setlocale(LC_ALL, "rus"); + int const n = 5; + struct Student *group[n]; + + for (int i = 0; i < n; i++) { + group[i] = inputData(i); + } + printGroup(group, n); + StudentsTwoCompareFunc(group); + FuncCompareStudent(group); + + + std::cout << "���������� �� �����" << std::endl; + Sort(group, n, CompareStudentsByName); + printGroup(group, n); + std::cout << "���������� �� �������" << std::endl; + Sort(group, n, CompareStudentsByl_name); + printGroup(group, n); + std::cout << "���������� �� �������� �����" << std::endl; + Sort(group, n, CompareStudentsBya_score); + printGroup(group, n); + + std::cout << "���������� ���� ������ \"�\" " << std::endl; + std::cout<< CountIf (group, n, StudentCompareName) << std::endl; + std::cout << "���������� ������� ������ \"�\" " << std::endl; + std::cout << CountIf(group, n, StudentCompareLname) << std::endl; + std::cout << "���������� �������� �� ������� ������ 8 " << std::endl; + std::cout << CountIf(group, n, StudentCompareAscore) << std::endl; + + FreeMem(group, n); + system("pause"); + return 0; +} + +struct Student* inputData(int n) +{ + struct Student *group = (struct Student*) malloc(sizeof (struct Student)); + std::cout << "��� �������� ����� " << n << " "; + std::cin >> group->name; + std::cout << "������� �������� ����� " << n << " "; + std::cin >> group->l_name; + std::cout << "������� ���� �������� ����� " << n << " "; + while (group->a_score < 0 || group->a_score >10) { + std::cin >> group->a_score; + } + return group; +} +void FreeMem(Student* g[], int n) +{ + for (int i = 0; i < n; i++) { + delete g[i]; + } +} + +void printGroup(Student**group, int count) +{ + for (int i = 0; i < count; ++i) + std::cout << "Name " << group[i]->name <<" l_name "<< group[i]->l_name << " a_score " << group[i]->a_score<< std::endl; +} + +int CompareStudentsByName(const struct Student* student1, const struct Student* student2) +{ + return strcmp(student1->name, student2->name); +} +int CompareStudentsByl_name(const struct Student* student1, const struct Student* student2) +{ + return strcmp(student1->l_name, student2->l_name); +} +int CompareStudentsBya_score(const struct Student* student1, const struct Student* student2) +{ + if (student1->a_score == student2->a_score){ + return 0; + } + if (student1->a_score > student2->a_score) { + return 1; + } + if (student1->a_score < student2->a_score) { + return -1; + } +} +void StudentsTwoCompareFunc(Student**group) +{ + int x1, x2, criterion=0; + + std::cout << "�������� ������ 1-��� 2-������� 3-������� ���� 4-�����" << std::endl; + while (criterion > 4 || criterion < 1) { + std::cin >> criterion; + } + if (criterion == 4) return; + std::cout << " N �������� 1 � N �������� 2 ?" << std::endl; + std::cin >> x1 >> x2; + if (criterion == 1) std::cout << CompareStudentsByName(group[x1], group[x2]) << std::endl; + if (criterion == 2) std::cout << CompareStudentsByl_name(group[x1], group[x2]) << std::endl; + if (criterion == 3) std::cout << CompareStudentsBya_score(group[x1], group[x2]) << std::endl; +} + + +void FuncCompareStudent(Student**group) +{ + int x, criterion=0; + std::cout << "�������� ������ 1-��� 2-������� 3-������� ���� 4-�����" << std::endl; + while (criterion > 4 || criterion < 1) { + std::cin >> criterion; + } + if (criterion == 4) return; + std::cout << " N �������� ?" << std::endl; + std::cin >> x; + + if (criterion == 1) { + std::cout << std::boolalpha << StudentCompareName(group[x]) << std::endl; + } + if (criterion == 2) { + std::cout << std::boolalpha << StudentCompareLname(group[x]) << std::endl; + } + if (criterion == 3) { + std::cout << std::boolalpha << StudentCompareAscore(group[x]) << std::endl; + } + +} +bool StudentCompareName(const struct Student* student) +{ + return (student->name[0] >= 'c'); +} +bool StudentCompareLname(const struct Student* student) +{ + return (student->l_name[0] >= 'c'); +} +bool StudentCompareAscore(const struct Student* student) +{ + return (student->a_score >= 8.0); +} + + +void Sort(struct Student** group, int n, CompareTwoStudentsFunc compare) +{ + struct Student *temp; + for (int j = 1; j < n; j++){ + for (int i = 0; i < n - j; i++){ + if (compare(group[i], group[i + 1]) == 1){ + temp = group[i]; + group[i] = group[i + 1]; + group[i + 1] = temp; + } + } + } +} + + +int CountIf(Student** group, int n, StudentCompareFunc compare) +{ + int count = 0; + for (int i = 0; i < n; i++) { + if (compare(group[i])) { + count++; + } + } + return count; +} \ No newline at end of file