#include <stdio.h>
int compVersions ( const char * version1, const char * version2 ) {
unsigned major1 = 0, minor1 = 0, bugfix1 = 0;
unsigned major2 = 0, minor2 = 0, bugfix2 = 0;
sscanf(version1
, "%u.%u.%u", &major1
, &minor1
, &bugfix1
); sscanf(version2
, "%u.%u.%u", &major2
, &minor2
, &bugfix2
); if (major1 < major2) return -1;
if (major1 > major2) return 1;
if (minor1 < minor2) return -1;
if (minor1 > minor2) return 1;
if (bugfix1 < bugfix2) return -1;
if (bugfix1 > bugfix2) return 1;
return 0;
}
int main ( ) {
int res = compVersions("4.3.2", "4.3.0");
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgY29tcFZlcnNpb25zICggY29uc3QgY2hhciAqIHZlcnNpb24xLCBjb25zdCBjaGFyICogdmVyc2lvbjIgKSB7Cgl1bnNpZ25lZCBtYWpvcjEgPSAwLCBtaW5vcjEgPSAwLCBidWdmaXgxID0gMDsKCXVuc2lnbmVkIG1ham9yMiA9IDAsIG1pbm9yMiA9IDAsIGJ1Z2ZpeDIgPSAwOwoJc3NjYW5mKHZlcnNpb24xLCAiJXUuJXUuJXUiLCAmbWFqb3IxLCAmbWlub3IxLCAmYnVnZml4MSk7Cglzc2NhbmYodmVyc2lvbjIsICIldS4ldS4ldSIsICZtYWpvcjIsICZtaW5vcjIsICZidWdmaXgyKTsKCWlmIChtYWpvcjEgPCBtYWpvcjIpIHJldHVybiAtMTsKCWlmIChtYWpvcjEgPiBtYWpvcjIpIHJldHVybiAxOwoJaWYgKG1pbm9yMSA8IG1pbm9yMikgcmV0dXJuIC0xOwoJaWYgKG1pbm9yMSA+IG1pbm9yMikgcmV0dXJuIDE7CglpZiAoYnVnZml4MSA8IGJ1Z2ZpeDIpIHJldHVybiAtMTsKCWlmIChidWdmaXgxID4gYnVnZml4MikgcmV0dXJuIDE7CglyZXR1cm4gMDsKfQoKCmludCBtYWluICggKSB7CiAgICBpbnQgcmVzID0gY29tcFZlcnNpb25zKCI0LjMuMiIsICI0LjMuMCIpOwogICAgcHJpbnRmKCIlZCIsIHJlcyk7Cn0=