#include <sstream>
#include <vector>
class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
* 比较版本号
* @param version1 string字符串
* @param version2 string字符串
* @return int整型
*/
int compare(string version1, string version2) {
// write code here
vector<int>a,b;
stringstream ss1(version1);
stringstream ss2(version2);
string t;
while(getline(ss1,t,'.')){
a.push_back(stoi(t));
}
while(getline(ss2,t,'.')){
b.push_back(stoi(t));
}
int i,j;
for(i=0,j=0;i<a.size()&&j<b.size();)
{
if(a[i]>b[j]) return 1;
else if(a[i]<b[j]) return -1;
else{
i++;j++;
}
}
if(i<a.size()){
while(i!=a.size()){
if(a[i++]!=0) return 1;
}
}
if(j<b.size())
while(j!=b.size()){
if(b[j++]!=0) return -1;
}
return 0;
}
};