class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 比较版本号
     * @param version1 string字符串 
     * @param version2 string字符串 
     * @return int整型
     */
    int compare(string version1, string version2) {
        // write code here
        

        while(version1.size()!=0 || version1.size()!=0 )
        {
            int len_1 = version1.size();
            int len_2 = version2.size();
            int v_1=0, v_2=0;

            int index_1=0, index_2=0;
            
            if(len_1!=0)
            {
                // 还没到最后一个修订号
                if(version1.find_first_of('.')!=string::npos)
                {
                    index_1 = version1.find_first_of('.');
                    v_1 = stoi(version1.substr(0,index_1));
                    version1 = version1.substr(index_1+1,len_1-index_1-1);
                }
                // 到最后一个修订号了
                else
                {
                    v_1 = stoi(version1);
                    version1 = "";
                }
            }
            
            if(len_2!=0)
            {
                if(version2.find_first_of('.')!=string::npos)
                {
                    index_2 =version2.find_first_of('.');
                    v_2 = stoi(version2.substr(0,index_2));
                    version2 = version2.substr(index_2+1,len_2-index_2-1);
                }
                else
                {
                    v_2 = stoi(version2);
                    version2="";
                }
            }
            
            if(v_1>v_2)
                return 1;
            else if(v_1<v_2)
                return -1;
        }

        return 0;
    }
};