diff --git a/.vs/Algorithm/v16/.suo b/.vs/Algorithm/v16/.suo
index 2f397a4..a3c70ec 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 d5c836b..fa288fe 100644
--- a/code/code.vcxproj
+++ b/code/code.vcxproj
@@ -142,17 +142,20 @@
+
+
+
diff --git a/code/code.vcxproj.filters b/code/code.vcxproj.filters
index 235fdd2..72a0c19 100644
--- a/code/code.vcxproj.filters
+++ b/code/code.vcxproj.filters
@@ -24,6 +24,9 @@
头文件
+
+ 头文件
+
@@ -38,6 +41,9 @@
源文件
+
+ 源文件
+
@@ -49,5 +55,8 @@
资源文件
+
+ 资源文件
+
\ No newline at end of file
diff --git a/code/config/4_IsPalindrome.ini b/code/config/4_IsPalindrome.ini
new file mode 100644
index 0000000..227c22e
--- /dev/null
+++ b/code/config/4_IsPalindrome.ini
@@ -0,0 +1,30 @@
+[Test1]
+Na=121
+nExpect=1
+[Test2]
+Na=123321
+nExpect=1
+[Test3]
+Na=214748367
+nExpect=0
+[Test4]
+Na=1212
+nExpect=0
+[Test5]
+Na=20
+nExpect=0
+[Test6]
+Na=-214748368
+nExpect=0
+[Test7]
+Na=-123321
+nExpect=0
+[Test8]
+Na=14333341
+nExpect=1
+[Test9]
+Na=3333333
+nExpect=1
+[Test10]
+Na=123454321
+nExpect=1
\ No newline at end of file
diff --git a/code/include/4_IsPalindrome.h b/code/include/4_IsPalindrome.h
new file mode 100644
index 0000000..6dec3d2
--- /dev/null
+++ b/code/include/4_IsPalindrome.h
@@ -0,0 +1,2 @@
+#pragma once
+bool IsPalindrome(int x);
\ No newline at end of file
diff --git a/code/src/4_IsPalindrome.cpp b/code/src/4_IsPalindrome.cpp
new file mode 100644
index 0000000..de0e6bd
--- /dev/null
+++ b/code/src/4_IsPalindrome.cpp
@@ -0,0 +1,26 @@
+#include "../include/4_IsPalindrome.h"
+//ĿжһǷΪ
+//˼·Դ֪Ǽλѭ%10/10,ȡÿλϵ֣*10ӣ
+// õת,ٺԭԱȡ
+
+bool IsPalindrome(int x)
+{
+ if (x < 0) //Ϊǻfalse
+ return false;
+ int x_Count = 1; //һcountͳƴǼλ
+ int x_Coln1 = x; //ѴһݣΪҪx
+ long long x_Turn = 0; //淭תֵintת
+ while ((x / 10) != 0) {//ͨѭǼλ
+ x_Count++;
+ x = x / 10;
+ }
+ x = x_Coln1; //ԭ滹Ҫõ
+ for (int i = 0; i < x_Count; i++) { //úŵx_TurnУ
+ int temp = x % 10; //ȡĸλ
+ x_Turn = x_Turn * 10 + temp; //ȡ
+ x = x / 10; //10ȡλ
+ }
+ if (x_Turn == x_Coln1) //жϷתԭǷ
+ return true;
+ return false;
+}
\ No newline at end of file
diff --git a/test/pch.h b/test/pch.h
index e96d9f0..8f8b714 100644
--- a/test/pch.h
+++ b/test/pch.h
@@ -17,6 +17,7 @@
#include"../code/include/1_ContainsNearbyDuplicate.h"
#include"../code/include/2_ExcelSheetColumnTitle.h"
#include"../code/include/3_IsUgly.h"
+#include"../code/include/4_IsPalindrome.h"
int CalcCount(int n, char(*str)[10], const char* FileName);
diff --git a/test/test.cpp b/test/test.cpp
index fd92a14..31600fe 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -5,6 +5,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"
+#define FileName_4 "../code/config/4_IsPalindrome.ini"
namespace test1
@@ -65,4 +66,22 @@ namespace test3
}
};
}
+namespace test4
+{
+ TEST_CLASS(UnitTest_4)
+ {
+ TEST_METHOD(TestMethode1)
+ {
+ char Section_Name[100][10] = { 0 };
+ int Section_Count = CalcCount(100, Section_Name, FileName_4);
+ CString Na, nExpect;
+ for (int i = 0; i < Section_Count; i++) {
+ GetPrivateProfileString(Section_Name[i], "Na", " ", Na.GetBuffer(20), 20, FileName_4);
+ GetPrivateProfileString(Section_Name[i], "nExpect", " ", nExpect.GetBuffer(20), 20, FileName_4);
+ bool nReal = IsPalindrome(_ttoi(Na));
+ Assert::AreEqual(nReal, CstrToBool(nExpect));
+ }
+ }
+ };
+}