diff --git a/Classwork14/Classwork14.sln b/Classwork14/Classwork14.sln new file mode 100644 index 0000000..a128612 --- /dev/null +++ b/Classwork14/Classwork14.sln @@ -0,0 +1,61 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34322.80 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "S14_1", "S14_1\S14_1.vcxproj", "{E97D04A0-D720-4DD8-9E96-1ABE93F570D6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "S14_2", "S14_2\S14_2.vcxproj", "{9A62E50D-E4D9-4803-B99A-C01F3206C2D8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "S14_3", "S14_3\S14_3.vcxproj", "{C7AF6FB4-6B2D-4DD8-918F-684D0AC77CBA}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "S14_4", "S14_4\S14_4.vcxproj", "{EF0F15AB-11D2-4E0C-9F19-610C995A37DF}" +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 + {E97D04A0-D720-4DD8-9E96-1ABE93F570D6}.Debug|x64.ActiveCfg = Debug|x64 + {E97D04A0-D720-4DD8-9E96-1ABE93F570D6}.Debug|x64.Build.0 = Debug|x64 + {E97D04A0-D720-4DD8-9E96-1ABE93F570D6}.Debug|x86.ActiveCfg = Debug|Win32 + {E97D04A0-D720-4DD8-9E96-1ABE93F570D6}.Debug|x86.Build.0 = Debug|Win32 + {E97D04A0-D720-4DD8-9E96-1ABE93F570D6}.Release|x64.ActiveCfg = Release|x64 + {E97D04A0-D720-4DD8-9E96-1ABE93F570D6}.Release|x64.Build.0 = Release|x64 + {E97D04A0-D720-4DD8-9E96-1ABE93F570D6}.Release|x86.ActiveCfg = Release|Win32 + {E97D04A0-D720-4DD8-9E96-1ABE93F570D6}.Release|x86.Build.0 = Release|Win32 + {9A62E50D-E4D9-4803-B99A-C01F3206C2D8}.Debug|x64.ActiveCfg = Debug|x64 + {9A62E50D-E4D9-4803-B99A-C01F3206C2D8}.Debug|x64.Build.0 = Debug|x64 + {9A62E50D-E4D9-4803-B99A-C01F3206C2D8}.Debug|x86.ActiveCfg = Debug|Win32 + {9A62E50D-E4D9-4803-B99A-C01F3206C2D8}.Debug|x86.Build.0 = Debug|Win32 + {9A62E50D-E4D9-4803-B99A-C01F3206C2D8}.Release|x64.ActiveCfg = Release|x64 + {9A62E50D-E4D9-4803-B99A-C01F3206C2D8}.Release|x64.Build.0 = Release|x64 + {9A62E50D-E4D9-4803-B99A-C01F3206C2D8}.Release|x86.ActiveCfg = Release|Win32 + {9A62E50D-E4D9-4803-B99A-C01F3206C2D8}.Release|x86.Build.0 = Release|Win32 + {C7AF6FB4-6B2D-4DD8-918F-684D0AC77CBA}.Debug|x64.ActiveCfg = Debug|x64 + {C7AF6FB4-6B2D-4DD8-918F-684D0AC77CBA}.Debug|x64.Build.0 = Debug|x64 + {C7AF6FB4-6B2D-4DD8-918F-684D0AC77CBA}.Debug|x86.ActiveCfg = Debug|Win32 + {C7AF6FB4-6B2D-4DD8-918F-684D0AC77CBA}.Debug|x86.Build.0 = Debug|Win32 + {C7AF6FB4-6B2D-4DD8-918F-684D0AC77CBA}.Release|x64.ActiveCfg = Release|x64 + {C7AF6FB4-6B2D-4DD8-918F-684D0AC77CBA}.Release|x64.Build.0 = Release|x64 + {C7AF6FB4-6B2D-4DD8-918F-684D0AC77CBA}.Release|x86.ActiveCfg = Release|Win32 + {C7AF6FB4-6B2D-4DD8-918F-684D0AC77CBA}.Release|x86.Build.0 = Release|Win32 + {EF0F15AB-11D2-4E0C-9F19-610C995A37DF}.Debug|x64.ActiveCfg = Debug|x64 + {EF0F15AB-11D2-4E0C-9F19-610C995A37DF}.Debug|x64.Build.0 = Debug|x64 + {EF0F15AB-11D2-4E0C-9F19-610C995A37DF}.Debug|x86.ActiveCfg = Debug|Win32 + {EF0F15AB-11D2-4E0C-9F19-610C995A37DF}.Debug|x86.Build.0 = Debug|Win32 + {EF0F15AB-11D2-4E0C-9F19-610C995A37DF}.Release|x64.ActiveCfg = Release|x64 + {EF0F15AB-11D2-4E0C-9F19-610C995A37DF}.Release|x64.Build.0 = Release|x64 + {EF0F15AB-11D2-4E0C-9F19-610C995A37DF}.Release|x86.ActiveCfg = Release|Win32 + {EF0F15AB-11D2-4E0C-9F19-610C995A37DF}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A696AB1E-F170-4B85-86AF-CAA41FC15BDA} + EndGlobalSection +EndGlobal diff --git a/Classwork14/S14_1/S14_1.cpp b/Classwork14/S14_1/S14_1.cpp new file mode 100644 index 0000000..38fc8d3 --- /dev/null +++ b/Classwork14/S14_1/S14_1.cpp @@ -0,0 +1,43 @@ +#include +#include +using namespace std; +class Tri +{ + double a, b, c; +public: + Tri(double x, double y, double z) + { + a = x; b = y; c = z; + } + double Peri() + { + return a + b + c; + } + double Area() + { + double s = Peri() / 2; + double area = sqrt(s * (s - a) * (s - b) * (s - c)); + return area; + } + void Show() + { + cout << "εı߳" << a << '\t' << b << '\t' << c << endl; + cout << "εܳ" << Peri() << endl; + cout << "ε" << Area() << endl << endl; + } +}; +int main() +{ + Tri tri1(3, 4, 5), tri2(5, 6, 7); + tri1.Show(); + tri2.Show(); + return 0; +} + +// εı߳3 4 5 +// εܳ12 +// ε6 +// +// εı߳5 6 7 +// εܳ18 +// ε14.6969 \ No newline at end of file diff --git a/Classwork14/S14_1/S14_1.vcxproj b/Classwork14/S14_1/S14_1.vcxproj new file mode 100644 index 0000000..fef396f --- /dev/null +++ b/Classwork14/S14_1/S14_1.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {e97d04a0-d720-4dd8-9e96-1abe93f570d6} + S141 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/Classwork14/S14_1/S14_1.vcxproj.filters b/Classwork14/S14_1/S14_1.vcxproj.filters new file mode 100644 index 0000000..d30ac21 --- /dev/null +++ b/Classwork14/S14_1/S14_1.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;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/Classwork14/S14_2/S14_2.cpp b/Classwork14/S14_2/S14_2.cpp new file mode 100644 index 0000000..3a5f8d4 --- /dev/null +++ b/Classwork14/S14_2/S14_2.cpp @@ -0,0 +1,56 @@ +#include +using namespace std; +class NUM +{ +private: + int n; + int* p; +public: + NUM(int n1) + { + n = n1; + p = new int[n]; + } + int yes(int x) + { + for (int i = 2; i <= x / 2; i++) + if (x % i == 0) + return 1; + return 0; + } + void fun() + { + int j; + for (int i = 3; 1; i++) + { + j = 0; + while (yes(i) == 1 && j < n) + { + p[j] = i; + j++; + i++; + } + if (j == n) + break; + } + } + void print() + { + for (int i = 0; i < n; i++) + cout << p[i] << "\t"; + cout << endl; + } + ~NUM() + { + if (p) delete[] p; + } +}; +int main() +{ + NUM num(10); + num.fun(); + num.print(); + return 0; +} + +// 114 115 116 117 118 119 120 121 122 123 \ No newline at end of file diff --git a/Classwork14/S14_2/S14_2.vcxproj b/Classwork14/S14_2/S14_2.vcxproj new file mode 100644 index 0000000..9153704 --- /dev/null +++ b/Classwork14/S14_2/S14_2.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {9a62e50d-e4d9-4803-b99a-c01f3206c2d8} + S142 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/Classwork14/S14_2/S14_2.vcxproj.filters b/Classwork14/S14_2/S14_2.vcxproj.filters new file mode 100644 index 0000000..291155c --- /dev/null +++ b/Classwork14/S14_2/S14_2.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;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/Classwork14/S14_3/S14_3.cpp b/Classwork14/S14_3/S14_3.cpp new file mode 100644 index 0000000..d37bf92 --- /dev/null +++ b/Classwork14/S14_3/S14_3.cpp @@ -0,0 +1,46 @@ +#include +using namespace std; +class STR +{ +private: + char* s1; + char* s2; +public: + STR(char* str) + { + s1 = str; + s2 = new char[strlen(str)]; + } + void delsame() + { + int i, j, k = 0; + for (i = 0; s1[i] != '\0'; i++) + { + for (j = 0; s2[j] != '\0'; j++) + if (s1[i] == s2[j]) + break; + if (s2[j] == '\0') + { + s2[k] = s1[i]; + k++; + } + } + s2[k] = '\0'; + } + void show() + { + cout << s2 << endl; + } + ~STR() + { + if (s2) delete[] s2; + } +}; +int main() +{ + char str[] = "concoon"; + STR test(str); + test.delsame(); + test.show(); + return 0; +} \ No newline at end of file diff --git a/Classwork14/S14_3/S14_3.vcxproj b/Classwork14/S14_3/S14_3.vcxproj new file mode 100644 index 0000000..3eaa8fe --- /dev/null +++ b/Classwork14/S14_3/S14_3.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {c7af6fb4-6b2d-4dd8-918f-684d0ac77cba} + S143 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/Classwork14/S14_3/S14_3.vcxproj.filters b/Classwork14/S14_3/S14_3.vcxproj.filters new file mode 100644 index 0000000..4441039 --- /dev/null +++ b/Classwork14/S14_3/S14_3.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;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/Classwork14/S14_4/S14_4.cpp b/Classwork14/S14_4/S14_4.cpp new file mode 100644 index 0000000..3bcc091 --- /dev/null +++ b/Classwork14/S14_4/S14_4.cpp @@ -0,0 +1,72 @@ +#include +#include +using namespace std; +class Circle +{ +private: + int num[20]; + int Max[4]; + int Min[4]; + int sum_max; + int sum_min; +public: + Circle() + { + srand(time(NULL)); + // srand(0); // For testing purpose + for(int i = 0; i < 20; i++) + num[i] = rand() % 100; + } + void Find_Max() + { + int temp[23]; + sum_max = 0, sum_min = 400; + for (int i = 0; i < 20; i++) + temp[i] = num[i]; + for (int i = 20; i < 23; i++) + temp[i] = num[i - 20]; + for (int i = 0; i < 4; i++) + Max[i] = Min[i] = temp[i] + temp[i + 1] + temp[i + 2] + temp[i + 3]; + for (int i = 4; i < 20; i++) + { + if (temp[i] + temp[i + 1] + temp[i + 2] + temp[i + 3] > sum_max) + { + Max[0] = temp[i]; + Max[1] = temp[i + 1]; + Max[2] = temp[i + 2]; + Max[3] = temp[i + 3]; + sum_max = Max[0] + Max[1] + Max[2] + Max[3]; + } + if (temp[i] + temp[i + 1] + temp[i + 2] + temp[i + 3] < sum_min) + { + Min[0] = temp[i]; + Min[1] = temp[i + 1]; + Min[2] = temp[i + 2]; + Min[3] = temp[i + 3]; + sum_min = Min[0] + Min[1] + Min[2] + Min[3]; + } + } + } + void Show() + { + cout << "Բе20ֱΪ" << endl; + for (int i = 0; i < 20; i++) + cout << num[i] << '\t'; + cout << endl; + cout << "Max = " << sum_max << endl; + for (int i = 0; i < 4; i++) + cout << Max[i] << '\t'; + cout << endl; + cout << "Min = " << sum_min << endl; + for (int i = 0; i < 4; i++) + cout << Min[i] << '\t'; + cout << endl; + } +}; +int main() +{ + Circle cir; + cir.Find_Max(); + cir.Show(); + return 0; +} \ No newline at end of file diff --git a/Classwork14/S14_4/S14_4.vcxproj b/Classwork14/S14_4/S14_4.vcxproj new file mode 100644 index 0000000..b7c2a40 --- /dev/null +++ b/Classwork14/S14_4/S14_4.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {ef0f15ab-11d2-4e0c-9f19-610c995a37df} + S144 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/Classwork14/S14_4/S14_4.vcxproj.filters b/Classwork14/S14_4/S14_4.vcxproj.filters new file mode 100644 index 0000000..ca0629a --- /dev/null +++ b/Classwork14/S14_4/S14_4.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;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/Classwork14/实验报告.doc b/Classwork14/实验报告.doc new file mode 100644 index 0000000..d031f34 Binary files /dev/null and b/Classwork14/实验报告.doc differ