leetcode165. 比较版本号

class Solution {
public:
    int compareVersion(string version1, string version2) {
        int i=0,j=0;
        while(i<version1.size()||j<version2.size()){
            long long  x=0;
            for(;i<version1.size()&&version1[i]!='.';i++){
                x=x*10+version1[i]-'0';
            }
            ++i;
            long long y=0;
            for(;j<version2.size()&&version2[j]!='.';j++){
                y=y*10+version2[j]-'0';
            }
            ++j;
            if(x!=y){
                return x>y?1:-1;
            }
        }
        return 0;
    }
};