Pārlūkot izejas kodu

1.新增空行位置功能
2.修改行数不一致问题

linxianzhi 2 gadi atpakaļ
vecāks
revīzija
36330a339d
2 mainītis faili ar 12 papildinājumiem un 2 dzēšanām
  1. 11 1
      MFCApplication1/AssignWords.cpp
  2. 1 1
      MFCApplication1/AssignWords.h

+ 11 - 1
MFCApplication1/AssignWords.cpp

@@ -187,8 +187,9 @@ void AssignWordsFromString(std::string strContent, int maxTwoWith, int maxTreeWi
 
 
 int AssignWordsFromTest(std::string pathName, std::vector<tuple< string, string>> &oneList, std::vector<tuple< string, string>> &twoList,
-	std::vector<tuple< string, string>> &threeList, std::vector<tuple< string, string>> &fourList)
+	std::vector<tuple< string, string>> &threeList, std::vector<tuple< string, string>> &fourList, int &ret)
 {
+	int nHangCount = 1;
 	// 词性处理
 	HMODULE module = GetModuleHandle(0);
 	TCHAR pFileName[MAX_PATH + 2] = { 0 };
@@ -238,6 +239,7 @@ int AssignWordsFromTest(std::string pathName, std::vector<tuple< string, string>
 			{
 				return -2;
 			}
+			
 			std::string strTemp = line,strTempAnother = lineOther;
 			UTF8toANSI(strTemp);
 			UTF8toANSI(strTempAnother);
@@ -245,10 +247,12 @@ int AssignWordsFromTest(std::string pathName, std::vector<tuple< string, string>
 				continue;
 			else if (strTemp == "")
 			{
+				ret = nHangCount;
 				return -3;
 			}
 			else if (strTempAnother == "")
 			{
+				ret = nHangCount;
 				return -4;
 			}
 			
@@ -270,6 +274,12 @@ int AssignWordsFromTest(std::string pathName, std::vector<tuple< string, string>
 			}
 			memset(line, 0, 4096);
 			memset(lineOther, 0, 4096);
+			nHangCount++;
+		}
+		// 源文件结束,查看答案文件是否结束
+		if (finOther.getline(lineOther, sizeof(lineOther)))
+		{
+			return -2;
 		}
 		
 	}

+ 1 - 1
MFCApplication1/AssignWords.h

@@ -19,4 +19,4 @@
 //         -4:内容行空,原数据行有数据
 /***********************************************************************/
 int AssignWordsFromTest(std::string pathName, std::vector<tuple< string, string>> &oneList, std::vector<tuple< string, string>> &twoList,
-	std::vector<tuple< string, string>> &errorList, std::vector<tuple< string, string>> &fourList);
+	std::vector<tuple< string, string>> &errorList, std::vector<tuple< string, string>> &fourList,int &ret);