#include <stdio.h>
int compare(char *str1, char *str2){
int ret = 0;
long str1_size = 0;
long str2_size = 0;
while(str1[str1_size] != '\0'){
str1_size++;
}
while(str2[str2_size] != '\0'){
str2_size++;
}
if(str1_size>str2_size){
ret = 1;
}
else if(str1_size==str2_size){
for(long i = str1_size-1; i>0; i--){
int digit1 = str1[i] - '0';
int digit2 = str2[i] - '0';
if(digit1>digit2){
ret =1;
break;
}
}
}
return ret;
}
int main(void) {
// your code goes here
printf("Pass %d\n", compare
("10","5")); printf("Pass %d\n", compare
("5","10")); printf("Pass %d\n", compare
("986","976")); printf("Pass %d\n", compare
("976","986")); printf("Pass %d\n", compare
("9765484986545645689798476546547","9765484986545645689798476546546")); printf("Pass %d\n", compare
("9765484986545645689798476546546","9765484986545645689798476586546")); printf("Pass %d\n", compare
("0","9765484986545645689798476586546"));
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgY29tcGFyZShjaGFyICpzdHIxLCBjaGFyICpzdHIyKXsKCQoJaW50IHJldCA9IDA7Cglsb25nIHN0cjFfc2l6ZSA9IDA7Cglsb25nIHN0cjJfc2l6ZSA9IDA7CgkKCXdoaWxlKHN0cjFbc3RyMV9zaXplXSAhPSAnXDAnKXsKCQlzdHIxX3NpemUrKzsKCX0KCQoJd2hpbGUoc3RyMltzdHIyX3NpemVdICE9ICdcMCcpewoJCXN0cjJfc2l6ZSsrOwoJfQoJCglpZihzdHIxX3NpemU+c3RyMl9zaXplKXsKCQlyZXQgPSAxOwoJfQoJZWxzZSBpZihzdHIxX3NpemU9PXN0cjJfc2l6ZSl7CgkJZm9yKGxvbmcgaSA9IHN0cjFfc2l6ZS0xOyBpPjA7IGktLSl7CgkJCWludCBkaWdpdDEgPSBzdHIxW2ldIC0gJzAnOwoJCQlpbnQgZGlnaXQyID0gc3RyMltpXSAtICcwJzsKCQkJaWYoZGlnaXQxPmRpZ2l0Mil7CgkJCQlyZXQgPTE7CgkJCQlicmVhazsKCQkJfQoJCX0KCX0KCQoJ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