diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4722506 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/test +*.exe \ No newline at end of file diff --git a/as1/.gitignore b/as1/.gitignore new file mode 100644 index 0000000..4722506 --- /dev/null +++ b/as1/.gitignore @@ -0,0 +1,2 @@ +/test +*.exe \ No newline at end of file diff --git a/as1/Fraction_test.cpp b/as1/Fraction_test.cpp index 72c150c..25a943f 100644 --- a/as1/Fraction_test.cpp +++ b/as1/Fraction_test.cpp @@ -9,7 +9,7 @@ int main() Fraction b(3,-4); Fraction c(5); Fraction d(-3.14); - Fraction e = 1.3333; + Fraction e = 1.333333; Fraction f = -b; @@ -78,6 +78,12 @@ int main() cout << "; b = " << b << endl << endl; + cout << "b += c; b = " << (b+=c) << endl; + cout << "b -= c; b = " << (b-=c) << endl; + cout << "b *= c; b = " << (b*=c) << endl; + cout << "b /= c; b = " << (b/=c) << endl << endl; + + cout << "if b > c ?? " << ((b>c)? "Yes" : "No") << endl; cout << "if b < c ?? " << ((b= c ?? " << ((b>=c)? "Yes" : "No") << endl; @@ -87,11 +93,6 @@ int main() cout << "if b != c ?? " << ((b!=c)? "Yes" : "No") << endl << endl; - cout << "b += c; b = " << (b+=c) << endl; - cout << "b -= c; b = " << (b-=c) << endl; - cout << "b *= c; b = " << (b*=c) << endl; - cout << "b /= c; b = " << (b/=c) << endl << endl; - cout << "Devide 0 test: "; try{ @@ -100,14 +101,21 @@ int main() cout << msg << endl; } + cout << endl << "************ This is the END of TEST section !! ************" << endl << endl; + cout << "Have a try by YOURSELF!! (Press Ctrl+C to quit)" << endl; + while(1){ - try{ - cout << endl << "Please Input a Fraction(-3/5) or a Decimals(e.g. 3.14): "; - cin >> a; - cout << a << endl; - }catch(const char* msg){ - cout << endl << msg << endl; - }} + + try{ + cout << endl << "Please Input a Fraction(-3/5) or a Decimals(e.g. 3.14): "; + cin >> a; + cout << a << endl; + }catch(const char* msg){ + cout << endl << msg << endl; + } + + + } return 0; } \ No newline at end of file diff --git a/as1/README.md b/as1/README.md new file mode 100644 index 0000000..9575d23 --- /dev/null +++ b/as1/README.md @@ -0,0 +1,12 @@ +## How to begin +Please execute the compilergcc.bat to compile.
+ +Or you can install gcc manually and use the following command to compile. +```` +$ g++ -O2 -o same_vec same_vec.cpp +$ g++ -O2 -o Fraction_test Fraction_test.cpp Fraction.h +```` + +## gcc Download url +**For windows** +https://yimian-setup.obs.myhwclouds.com/setup/tdm64-gcc-5.1.0-2.exe diff --git a/as1/compilergcc.bat b/as1/compilergcc.bat new file mode 100644 index 0000000..4ea49cf --- /dev/null +++ b/as1/compilergcc.bat @@ -0,0 +1,38 @@ +@echo off +where g++>nul +cls +if errorlevel 1 ( +echo gcc NOT FOUND in your computer!! +echo Press any key to start installation! +pause>nul +goto install +) else ( +echo Detected gcc Environment.. +echo Start to compile!! +goto compile +) + + + +:install +cls +echo Please download and run the gcc install program. +ping 127.0.0.1 >nul +start https://yimian-setup.obs.myhwclouds.com/setup/tdm64-gcc-5.1.0-2.exe +ping 127.0.0.1 >nul +cls +echo After install, Please restart this script to compile!!&&pause&&exit + + +:compile +cls +echo compiling... +g++ -O2 -o same_vec same_vec.cpp +g++ -O2 -o Fraction_test Fraction_test.cpp Fraction.h +cls +echo compile finished! The program is in current folder! +pause + +exit + +