fork download
  1. # include <stdio.h>
  2.  
  3. int fuzzyStrcmp(char s[], char t[]){
  4. //関数の中だけを書き換えてください
  5. //同じとき1を返す,異なるとき0を返す
  6. int i;
  7. while (s[i] != '\0' && t[i] != '\0') {
  8. char c1 = s[i];
  9. char c2 = t[i];
  10.  
  11. // 大文字を小文字に変換
  12. if (c1 >= 'A' && c1 <= 'Z') {
  13. c1 = c1 + 32;
  14. }
  15. if (c2 >= 'A' && c2 <= 'Z') {
  16. c2 = c2 + 32;
  17. }
  18.  
  19. // 比較
  20. if (c1 != c2) {
  21. return 0; // 異なる
  22. }
  23.  
  24. i++;
  25. }
  26.  
  27. // 文字列の長さが異なる場合もチェック
  28. if (s[i] != '\0' || t[i] != '\0') {
  29. return 0;
  30. }
  31.  
  32. return 1; // 同じ
  33. }
  34.  
  35.  
  36. //メイン関数は書き換えなくてできます
  37. int main(){
  38. int ans;
  39. char s[100];
  40. char t[100];
  41. scanf("%s %s",s,t);
  42. printf("%s = %s -> ",s,t);
  43. ans = fuzzyStrcmp(s,t);
  44. printf("%d\n",ans);
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0.01s 5284KB
stdin
abCD AbCd
stdout
abCD = AbCd -> 1