Local int compare_string(unsigned char *a, unsigned char *b) { int i = 0; int j = 0; unsigned char al; unsigned char bl; while((a[i] != EOS) || (b[j] != EOS)) { if(a[i] == EOS) return(-1); if(b[j] == EOS) return(1); if(blank_ignore) { if(a[i] == SPC) i++; if(b[j] == SPC) j++; } al = TOLOWER(a[i]); bl = TOLOWER(b[j]); if(al != bl) return(charcmp(al, bl)); i++; j++; } return(mystrcmp(a, b)); }
int main(int argc, char const *argv[]){ char ent[1005], test[1005]; int a, j = 1, cont, bate; scanf("%d", &a); while(j <= a){ bate = 0; cont = 1; scanf("%s %s", ent, test); while(cont <= strlen(test)){ if(strlen(ent) - cont < 0 || strlen(test) - cont < 0){ goto s1; } if(charcmp(ent[strlen(ent) - cont],test[strlen(test) - cont]) == 0){ bate += 0; } else{ bate += 1; } cont++; } s1: if(bate != 0){ printf("nao encaixa\n"); } else{ printf("encaixa\n"); } j++; } return 0; }
int pstrcasecmp(const void *p1, const void *p2) { char * const *s1 = p1; char * const *s2 = p2; return charcmp(*s1, *s2); }
/* * overwrites <str> to common prefix of <str> and <newstr> * if <str> is equal to <newstr> returns <str>+strlen(<str>)+1 * otherwise returns <str>+strlen(<str>) */ static char *overlaid(register char *str,register const char *newstr,int nocase) { register int c,d; while((c= *(unsigned char *)str) && ((d= *(unsigned char*)newstr++),charcmp(c,d,nocase))) str++; if(*str) *str = 0; else if(*newstr==0) str++; return(str); }
// // Overwrites <str> to common prefix of <str> and <newstr>. If <str> is equal to <newstr> returns // <str>+strlen(<str>)+1 otherwise returns <str>+strlen(<str>). // static char *overlaid(char *str, const char *newstr, int nocase) { int c, d; while ((c = *(unsigned char *)str) && ((d = *(unsigned char *)newstr++), charcmp(c, d, nocase))) { str++; } if (*str) { *str = 0; } else if (*newstr == 0) { str++; } return str; }