说实话一开始题目都看不懂
这道题还是有些需要留意的

class Solution {
public:
    int compare(string version1, string version2) {
      int s1_size = version1.size(), s2_size = version2.size();
      int s1_index = 0, s2_index = 0;
      
        //  两个字符串都到结尾时才终止
      while (s1_index < s1_size || s2_index < s2_size) {
        long long num1 = 0;
        
        while (s1_index < s1_size && version1[s1_index] != '.') {
          num1 = num1 * 10 + (version1[s1_index] - '0');
          ++s1_index;
        }
        ++s1_index;
        
        long long num2 = 0;
        
        while (s2_index < s2_size && version2[s2_index] != '.') {
          num2 = num2 * 10 + (version2[s2_index] - '0');
          ++s2_index;
        }
        ++s2_index;
        
        if (num1 > num2) {
          return 1;
        }
        
        if (num1 < num2) {
          return -1;
        }
      }
      
      return 0;
    }
};