fork download
  1. #include <stdio.h>
  2.  
  3.  
  4. int fuzzyStrcmp(char s[], char t[]) {
  5. int i;
  6. for (i = 0; s[i] != '\0' && t[i] != '\0'; i++) {
  7. char c1 = s[i];
  8. char c2 = t[i];
  9.  
  10.  
  11. if ('A' <= c1 && c1 <= 'Z') c1 = c1 + 32;
  12. if ('A' <= c2 && c2 <= 'Z') c2 = c2 + 32;
  13.  
  14. if (c1 != c2) {
  15. return 0;
  16. }
  17. }
  18.  
  19. if (s[i] == '\0' && t[i] == '\0') {
  20. return 1;
  21. }
  22.  
  23. return 0;
  24. }
  25.  
  26. int main(void) {
  27.  
  28. printf("abC と Abc の比較: %d\n", fuzzyStrcmp("abC", "Abc"));
  29. printf("abc と abc の比較: %d\n", fuzzyStrcmp("abc", "abc"));
  30. printf("abx と Aby の比較: %d\n", fuzzyStrcmp("abx", "Aby"));
  31.  
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
abC と Abc の比較: 1
abc と abc の比較: 1
abx と Aby の比較: 0