forked from Amadeus-1048/Course-Review
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28735a3
commit c327a1a
Showing
36 changed files
with
3,007 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_project_file> | ||
<FileVersion major="1" minor="6" /> | ||
<Project> | ||
<Option title="16CPP2" /> | ||
<Option pch_mode="2" /> | ||
<Option compiler="gcc" /> | ||
<Build> | ||
<Target title="Debug"> | ||
<Option output="bin/Debug/16CPP2" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Debug/" /> | ||
<Option type="1" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-g" /> | ||
</Compiler> | ||
</Target> | ||
<Target title="Release"> | ||
<Option output="bin/Release/16CPP2" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Release/" /> | ||
<Option type="1" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-O2" /> | ||
</Compiler> | ||
<Linker> | ||
<Add option="-s" /> | ||
</Linker> | ||
</Target> | ||
</Build> | ||
<Compiler> | ||
<Add option="-Wall" /> | ||
<Add option="-fexceptions" /> | ||
</Compiler> | ||
<Unit filename=".\main.cpp" /> | ||
<Unit filename=".\test02.cpp" /> | ||
<Unit filename=".\test0301.cpp" /> | ||
<Unit filename=".\test0302.cpp" /> | ||
<Unit filename=".\test0303.cpp" /> | ||
<Unit filename=".\test04.cpp" /> | ||
<Extensions> | ||
<code_completion /> | ||
<envvars /> | ||
<debugger /> | ||
<lib_finder disable_auto="1" /> | ||
</Extensions> | ||
</Project> | ||
</CodeBlocks_project_file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# depslib dependency file v1.0 | ||
1511845423 source:e:\lq\���ƽ�ѧ\08305121cpp\��������\cpp2�Ծ���\16��oop����\16cpp2\main.cpp | ||
<iostream> | ||
<conio.h> | ||
|
||
1512012590 source:e:\lq\���ƽ�ѧ\08305121cpp\��������\cpp2�Ծ���\16��oop����\16cpp2\test02.cpp | ||
<iostream> | ||
<cstring> | ||
|
10 changes: 10 additions & 0 deletions
10
面向对象程序设计/历年卷/《面向对象程序设计》近3年试卷/16级OOP试题/16CPP2/16CPP2.layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_layout_file> | ||
<FileVersion major="1" minor="0" /> | ||
<ActiveTarget name="Debug" /> | ||
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="0" topLine="0" /> | ||
</Cursor> | ||
</File> | ||
</CodeBlocks_layout_file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
[Project] | ||
name=16CPP2 | ||
type=0 | ||
defaultConfig=0 | ||
|
||
[Debug] | ||
// compiler | ||
workingDirectory= | ||
arguments= | ||
intermediateFilesDirectory=Debug | ||
outputFilesDirectory=Debug | ||
compilerPreprocessor= | ||
extraCompilerOptions= | ||
compilerIncludeDirectory= | ||
noWarning=0 | ||
defaultWarning=0 | ||
allWarning=1 | ||
extraWarning=0 | ||
isoWarning=0 | ||
warningsAsErrors=0 | ||
debugType=1 | ||
debugLevel=2 | ||
exceptionEnabled=1 | ||
runtimeTypeEnabled=1 | ||
optimizeLevel=0 | ||
|
||
// linker | ||
libraryPath= | ||
outputFilename=Debug\16CPP2.exe | ||
libraries= | ||
extraLinkerOptions= | ||
ignoreStartupFile=0 | ||
ignoreDefaultLibs=0 | ||
stripExecutableFile=0 | ||
|
||
// archive | ||
extraArchiveOptions= | ||
|
||
//resource | ||
resourcePreprocessor= | ||
resourceIncludeDirectory= | ||
extraResourceOptions= | ||
|
||
[Release] | ||
// compiler | ||
workingDirectory= | ||
arguments= | ||
intermediateFilesDirectory=Release | ||
outputFilesDirectory=Release | ||
compilerPreprocessor= | ||
extraCompilerOptions= | ||
compilerIncludeDirectory= | ||
noWarning=0 | ||
defaultWarning=0 | ||
allWarning=1 | ||
extraWarning=0 | ||
isoWarning=0 | ||
warningsAsErrors=0 | ||
debugType=0 | ||
debugLevel=0 | ||
exceptionEnabled=1 | ||
runtimeTypeEnabled=1 | ||
optimizeLevel=2 | ||
|
||
// linker | ||
libraryPath= | ||
outputFilename=Release\16CPP2.exe | ||
libraries= | ||
extraLinkerOptions= | ||
ignoreStartupFile=0 | ||
ignoreDefaultLibs=0 | ||
stripExecutableFile=1 | ||
|
||
// archive | ||
extraArchiveOptions= | ||
|
||
//resource | ||
resourcePreprocessor= | ||
resourceIncludeDirectory= | ||
extraResourceOptions= | ||
|
||
[Source] | ||
1=.\main.cpp | ||
2=.\test02.cpp | ||
3=.\test0301.cpp | ||
4=.\test0302.cpp | ||
5=.\test0303.cpp | ||
6=.\test04.cpp | ||
[Header] | ||
[Resource] | ||
[Other] | ||
[History] | ||
test04.cpp,2800 | ||
test0303.cpp,0 | ||
test0302.cpp,0 | ||
test0301.cpp,0 | ||
test02.cpp,0 | ||
main.cpp,34 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// main.cpp | ||
#include <iostream> | ||
#include <conio.h> | ||
using namespace std; | ||
|
||
int Test02(), Test0301(), Test0302(), Test0303(), Test04(); // 函数原型用于函数声明 | ||
|
||
int main() | ||
{ | ||
int (*f[])() = {Test02, Test0301, Test0302, Test0303, Test04}; | ||
// 定义指向函数入口地址的指针数组,并用已经存在的函数进行初始化 | ||
int n = sizeof(f)/sizeof(*f), choice; // n为数组f的元素个数 | ||
// 这样,如果需要增加一个测试函数,仅需要在第6行声明、第10行添加一个初始化元素。 | ||
// 如果要减少一个测试函数,仅在第10行删除相应数组初始化元素即可。主函数的其余部分不必修改 | ||
|
||
while(true) | ||
{ | ||
cout << "Testing 1 -- " << n << ", (0--exit): "; | ||
choice = getche()-'0'; | ||
cout << endl; | ||
if(choice<=0) | ||
break; | ||
if(choice<=n) | ||
f[choice-1](); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// test02.cpp | ||
#include <iostream> | ||
#include <cstring> | ||
using namespace std; | ||
|
||
template <typename T> void SWAP1(T &x, T &y) | ||
{ | ||
T temp = x; | ||
x = y; y = temp; | ||
} | ||
|
||
template <typename T> void SWAP2(T *x, T *y) | ||
{ | ||
T temp = *x; | ||
*x = *y; *y = temp; | ||
} | ||
|
||
template <typename T> void SWAP3(T *&x, T *&y) | ||
{ | ||
T *temp = x; | ||
x = y; y = temp; | ||
} | ||
|
||
int Test02() | ||
{ | ||
int m = 3, n = 5; | ||
double a = 3.3, b = 5.5; | ||
char *str1, *str2; | ||
str1 = new char[80]; | ||
str2 = new char[80]; | ||
strcpy(str1, "Tom"); | ||
strcpy(str2, "Jerry"); | ||
|
||
SWAP1(m, n); | ||
cout << "m = " << m << ", n = " << n << endl; | ||
SWAP2(&a, &b); | ||
cout << "a = " << a << ", b = " << b << endl; | ||
SWAP3(str1, str2); | ||
cout << "str1: " << str1 << ", str2: " << str2 << endl; | ||
delete [] str1; | ||
delete [] str2; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// test0301.cpp | ||
#include <iostream> | ||
#include <cstdlib> | ||
using namespace std; | ||
|
||
class Complex | ||
{ | ||
public: | ||
Complex(double real=0, double imag=0): re(real), im(imag) {} | ||
friend Complex operator+(const Complex &x, const Complex &y) | ||
{ | ||
return Complex(x.re+y.re, x.im+y.im); | ||
} | ||
Complex & operator+=(const Complex &x) | ||
{ | ||
re += x.re; | ||
im += x.im; | ||
return *this; | ||
} | ||
Complex & operator++() | ||
{ | ||
re++; | ||
return *this; | ||
} | ||
Complex operator++(int) | ||
{ | ||
Complex temp(*this); | ||
re++; | ||
return temp; | ||
} | ||
friend ostream & operator<<(ostream &out, const Complex &c) | ||
{ | ||
out << '(' << c.re << ", " << c.im << ')'; | ||
return out; | ||
} | ||
friend istream & operator>>(istream &in, Complex &c) | ||
{ | ||
char str[80]; | ||
in.getline(str, 80, '('); | ||
in.getline(str, 80, ','); | ||
c.re = atof(str); | ||
in.getline(str, 80, ')'); | ||
c.im = atof(str); | ||
return in; | ||
} | ||
private: | ||
double re, im; | ||
}; | ||
|
||
int Test0301() | ||
{ | ||
Complex a, b(3, 4), c, d; | ||
c = 5 + b; | ||
d = b + 5; | ||
cout << "a : " << a << endl; | ||
cout << "b : " << b << endl; | ||
cout << "c : " << c << endl; | ||
cout << "d : " << d << endl; | ||
cout << "++a : " << ++a << endl; | ||
cout << "a : " << a << endl; | ||
cout << "b++ : " << b++ << endl; | ||
cout << "b : " << b << endl; | ||
cout << "a += b : " << (a += b) << endl; | ||
cout << "a += a : " << (a += a) << endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// test0302.cpp | ||
#include <iostream> | ||
using namespace std; | ||
|
||
class Language | ||
{ | ||
public: | ||
virtual void SayHello() const | ||
{ | ||
cout << "How are you!" << endl; | ||
} | ||
virtual void SayByebye() const | ||
{ | ||
cout << "Goodbye!" << endl; | ||
} | ||
}; | ||
|
||
class Chinese : public Language | ||
{ | ||
public: | ||
void SayHello() const | ||
{ | ||
cout << "低挫�" << endl; | ||
} | ||
void SayByebye() const | ||
{ | ||
cout << "壅需�" << endl; | ||
} | ||
}; | ||
|
||
class Japanese : public Language | ||
{ | ||
public: | ||
void SayHello() const | ||
{ | ||
cout << "こんにちは!" << endl; | ||
} | ||
void SayByebye() const | ||
{ | ||
cout << "さようなら!" << endl; | ||
} | ||
}; | ||
|
||
class English : public Language | ||
{ | ||
public: | ||
void SayHello() const | ||
{ | ||
cout << "Hello!" << endl; | ||
} | ||
void SayByebye() const | ||
{ | ||
cout << "Bye-bye!" << endl; | ||
} | ||
}; | ||
|
||
int test0302A(const Language &p) | ||
{ | ||
p.SayHello(); | ||
p.SayByebye(); | ||
return 0; | ||
} | ||
|
||
int test0302B(const Language *p) | ||
{ | ||
p->SayHello(); | ||
p->SayByebye(); | ||
return 0; | ||
} | ||
|
||
int test0302C(const Language p) | ||
{ | ||
p.SayHello(); | ||
p.SayByebye(); | ||
return 0; | ||
} | ||
|
||
int Test0302() | ||
{ | ||
Chinese c; | ||
Japanese j; | ||
English e; | ||
|
||
test0302A(c); | ||
test0302A(j); | ||
test0302A(e); | ||
|
||
test0302B(&c); | ||
test0302C(c); | ||
return 0; | ||
} |
Oops, something went wrong.