标签:
1.0 == 1
class Solution {
public:
int compareVersion(string version1, string version2) {
stringstream streamVer1(version1);
stringstream streamVer2(version2);
string strVer1, strVer2;
while (!streamVer1.eof() || !streamVer2.eof())
{
int iVer1(0), iVer2(0);
if (!streamVer1.eof())
{
getline(streamVer1, strVer1, ‘.‘);
iVer1 = stoi(strVer1);
}
if (!streamVer2.eof())
{
getline(streamVer2, strVer2, ‘.‘);
iVer2 = stoi(strVer2);
}
if (iVer1 > iVer2)
{
return 1;
}
if (iVer1 < iVer2)
{
return -1;
}
}
return 0;
}
};
标签:
原文地址:http://www.cnblogs.com/flyjameschen/p/4318197.html