fork(1) download
  1. #include <stdio.h>
  2. #include <ctype.h> // tolower関数を使用するために追加
  3.  
  4. int fuzzyStrcmp(char s[], char t[]){
  5. //関数の中だけを書き換えてください
  6. //同じとき1を返す,異なるとき0を返す
  7. int i = 0;
  8. while (s[i] != '\0' && t[i] != '\0') {
  9. // 大文字・小文字を無視して比較するため小文字に統一
  10. if (tolower(s[i]) != tolower(t[i])) {
  11. return 0; // 途中で一致しない文字があれば0を返す
  12. }
  13. i++;
  14. }
  15.  
  16. // 両方の文字列が同時に終端('\0')に達していれば一致
  17. if (s[i] == '\0' && t[i] == '\0') {
  18. return 1;
  19. } else {
  20. return 0; // 長さが異なる場合は0を返す
  21. }
  22. }
  23.  
  24. //メイン関数は書き換えなくてできます
  25. int main(){
  26. int ans;
  27. char s[100];
  28. char t[100];
  29. scanf("%s %s",s,t);
  30. printf("%s = %s -> ",s,t);
  31. ans = fuzzyStrcmp(s,t);
  32. printf("%d\n",ans);
  33. return 0;
  34. }
Success #stdin #stdout 0s 5308KB
stdin
abCD
abcde
stdout
abCD = abcde -> 0