#include <stdio.h>
#include <string.h>
char a[]={"1.1.110"};
char b[]={"1.1.70"};
char c[]={"1.2.11"};
char d[]={"1.2.100"};
int VersionCompare(char * version1, char* version2)
{
int index1 = 0;
int index2 = 0;
while (index1 < strlen(version1) || index2 < strlen(version2))
{
int num1 = 0;
int num2 = 0;
while ((index1 < strlen(version1)) && (version1[index1] != '.'))
{
num1 = num1 * 10 + (version1[index1] - '0');
index1++;
}
while ((index2 < strlen(version2)) && (version2[index2] != '.'))
{
num2 = num2 * 10 + (version2[index2] - '0');
index2++;
}
printf("n1 %d ",num1);
printf("n2 %d ",num2);
if (num1 > num2)
{
return 1;
}
if (num1 < num2)
{
return -1;
}
index1++;
index2++;
}
return 0;
}
int main () {
printf("hello https://tool.lu/\n");
printf("str %d",VersionCompare(a,b));
return 0;
}
|