fork(1) download
  1. #include <stdio.h>
  2. #include <ctype.h> // tolower関数を使うために必要
  3.  
  4. int fuzzyStrcmp(char s[], char t[]){
  5. int i = 0;
  6. while (s[i] != '\0' && t[i] != '\0') {
  7. if (tolower(s[i]) != tolower(t[i])) {
  8. return 0; // 一文字でも違えば 0 を返す
  9. }
  10. i++;
  11. }
  12. // 両方の文字列が同時に終わっていれば同じ
  13. if (s[i] == '\0' && t[i] == '\0') {
  14. return 1;
  15. } else {
  16. return 0;
  17. }
  18. }
  19.  
  20. int main(){
  21. int ans;
  22. char s[100];
  23. char t[100];
  24. scanf("%s %s",s,t);
  25. printf("%s = %s -> ",s,t);
  26. ans = fuzzyStrcmp(s,t);
  27. printf("%d\n",ans);
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5284KB
stdin
abCD AbCd
stdout
abCD = AbCd -> 1