diff --git a/.gitignore b/.gitignore
index c4154dd..2eb6e37 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,6 @@
*.txt
*.ilk
*.exp
+*.db-wal
+*.db-shm
+*.opendb
diff --git a/.vs/Algorithm/v16/.suo b/.vs/Algorithm/v16/.suo
index a6bcb9e..2f397a4 100644
Binary files a/.vs/Algorithm/v16/.suo and b/.vs/Algorithm/v16/.suo differ
diff --git a/code/code.vcxproj b/code/code.vcxproj
index 6986421..d5c836b 100644
--- a/code/code.vcxproj
+++ b/code/code.vcxproj
@@ -141,15 +141,18 @@
+
+
+
diff --git a/code/code.vcxproj.filters b/code/code.vcxproj.filters
index 279cc21..235fdd2 100644
--- a/code/code.vcxproj.filters
+++ b/code/code.vcxproj.filters
@@ -21,6 +21,9 @@
头文件
+
+ 头文件
+
@@ -32,6 +35,9 @@
源文件
+
+ 源文件
+
@@ -40,5 +46,8 @@
资源文件
+
+ 资源文件
+
\ No newline at end of file
diff --git a/code/config/3_IsUgly.ini b/code/config/3_IsUgly.ini
new file mode 100644
index 0000000..ccaeef9
--- /dev/null
+++ b/code/config/3_IsUgly.ini
@@ -0,0 +1,30 @@
+[Test1]
+Na=6
+nExpect=1
+[Test2]
+Na=3
+nExpect=1
+[Test3]
+Na=14
+nExpect=0
+[Test4]
+Na=15
+nExpect=1
+[Test5]
+Na=20
+nExpect=1
+[Test6]
+Na=-1
+nExpect=0
+[Test7]
+Na=2
+nExpect=1
+[Test8]
+Na=1
+nExpect=1
+[Test9]
+Na=2019
+nExpect=0
+[Test10]
+Na=2147483647
+nExpect=0
\ No newline at end of file
diff --git a/code/include/3_IsUgly.h b/code/include/3_IsUgly.h
new file mode 100644
index 0000000..b0585bf
--- /dev/null
+++ b/code/include/3_IsUgly.h
@@ -0,0 +1,3 @@
+#pragma once
+#include
+bool IsUgly(int num);
\ No newline at end of file
diff --git a/code/src/3_IsUgly.cpp b/code/src/3_IsUgly.cpp
new file mode 100644
index 0000000..22a01d6
--- /dev/null
+++ b/code/src/3_IsUgly.cpp
@@ -0,0 +1,28 @@
+#include "../include/3_IsUgly.h "
+//ĿжһǷΪܱ2 3 5ܷtrueܷfalse
+//˼·1.ѭж%2%3%5ǷΪ0Ӧѭ
+// 2.numжϣΪ1˵ܱ235dzǡ
+bool IsUgly(int num)
+{
+ if (num <= 0){ //жϣСڵ0ֱӷfalse
+ return false;
+ }
+ while (1) { //numѭжϲӦ㣬ֱ˳ѭ
+ if (num % 2 == 0) {
+ num = num / 2;
+ }
+ else if (num % 3 == 0) {
+ num = num / 3;
+ }
+ else if (num % 5 == 0) {
+ num = num / 5;
+ }
+ else {
+ break;
+ }
+ }
+ if (num == 1) { //numжϣΪ1˵ܱdzdzfalse
+ return true;
+ }
+ return false;
+}
\ No newline at end of file
diff --git a/test/pch.h b/test/pch.h
index a50326e..e96d9f0 100644
--- a/test/pch.h
+++ b/test/pch.h
@@ -16,6 +16,7 @@
#include"../code/include/1_ContainsNearbyDuplicate.h"
#include"../code/include/2_ExcelSheetColumnTitle.h"
+#include"../code/include/3_IsUgly.h"
int CalcCount(int n, char(*str)[10], const char* FileName);
diff --git a/test/test.cpp b/test/test.cpp
index 55aaa7f..fd92a14 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -4,6 +4,7 @@
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
#define FileName_1 "../code/config/1_ContainsNearbyDuplicate.ini"
#define FileName_2 "../code/config/2_ExcelSheetColumnTiTle.ini"
+#define FileName_3 "../code/config/3_IsUgly.ini"
namespace test1
@@ -46,4 +47,22 @@ namespace test2
}
};
}
+namespace test3
+{
+ TEST_CLASS(UnitTest_1)
+ {
+ TEST_METHOD(TestMethode1)
+ {
+ char Section_Name[100][10] = { 0 };
+ int Section_Count = CalcCount(100, Section_Name, FileName_3);
+ CString Na, nExpect;
+ for (int i = 0; i < Section_Count; i++) {
+ GetPrivateProfileString(Section_Name[i], "Na", " ", Na.GetBuffer(20), 20, FileName_3);
+ GetPrivateProfileString(Section_Name[i], "nExpect", " ", nExpect.GetBuffer(20), 20, FileName_3);
+ bool nReal = IsUgly(_ttoi(Na));
+ Assert::AreEqual(nReal, CstrToBool(nExpect));
+ }
+ }
+ };
+}