int str_comparacao(char str1[], char str2[]) {
int i;
for (i = 0; str1[i] == str2[i] && str1[i] != 0; i++) {}
return str1[i] - str2[i];
}
void teste(char str1[], char str2[]) {
int resultado = str_comparacao(str1, str2);
char c = resultado < 0 ? '<' : resultado > 0 ? '>' : '=';
printf("%s %c %s\n", str1
, c
, str2
); }
int main() {
teste("Vermelho", "Verde");
teste("Verde", "Verde");
teste("Verde", "Vermelho");
teste("Verde", "Cinza");
teste("Cinza", "Verde");
}
aW50IHN0cl9jb21wYXJhY2FvKGNoYXIgc3RyMVtdLCBjaGFyIHN0cjJbXSkgewogICAgaW50IGk7CiAgICBmb3IgKGkgPSAwOyBzdHIxW2ldID09IHN0cjJbaV0gJiYgc3RyMVtpXSAhPSAwOyBpKyspIHt9CiAgICByZXR1cm4gc3RyMVtpXSAtIHN0cjJbaV07Cn0KCnZvaWQgdGVzdGUoY2hhciBzdHIxW10sIGNoYXIgc3RyMltdKSB7CiAgICBpbnQgcmVzdWx0YWRvID0gc3RyX2NvbXBhcmFjYW8oc3RyMSwgc3RyMik7CiAgICBjaGFyIGMgPSByZXN1bHRhZG8gPCAwID8gJzwnIDogcmVzdWx0YWRvID4gMCA/ICc+JyA6ICc9JzsKICAgIHByaW50ZigiJXMgJWMgJXNcbiIsIHN0cjEsIGMsIHN0cjIpOwp9CgppbnQgbWFpbigpIHsKICAgIHRlc3RlKCJWZXJtZWxobyIsICJWZXJkZSIpOwogICAgdGVzdGUoIlZlcmRlIiwgIlZlcmRlIik7CiAgICB0ZXN0ZSgiVmVyZGUiLCAiVmVybWVsaG8iKTsKICAgIHRlc3RlKCJWZXJkZSIsICJDaW56YSIpOwogICAgdGVzdGUoIkNpbnphIiwgIlZlcmRlIik7Cn0=