fork download
  1. # include <stdio.h>
  2.  
  3. int fuzzyStrcmp(char s[], char t[]){
  4. //関数の中だけを書き換えてください
  5. //同じとき1を返す,異なるとき0を返す
  6. int i = 0;
  7. while (s[i] != '\0' && t[i] != '\0') {
  8. char cs = s[i];
  9. char ct = t[i];
  10.  
  11. // 小文字なら大文字に変換
  12. if (cs >= 'a' && cs <= 'z') {
  13. cs -= 'a' - 'A';
  14. }
  15. if (ct >= 'a' && ct <= 'z') {
  16. ct -= 'a' - 'A';
  17. }
  18.  
  19. if (cs != ct) {
  20. return 0;
  21. }
  22. i++;
  23. }
  24. // 両方とも終端に達していれば一致
  25. if (s[i] == '\0' && t[i] == '\0') {
  26. return 1;
  27. } else {
  28. return 0;
  29. }
  30. }
  31.  
  32.  
  33. //メイン関数は書き換えなくてできます
  34. int main(){
  35. int ans;
  36. char s[100];
  37. char t[100];
  38. scanf("%s %s",s,t);
  39. printf("%s = %s -> ",s,t);
  40. ans = fuzzyStrcmp(s,t);
  41. printf("%d\n",ans);
  42. return 0;
  43. }
  44.  
Success #stdin #stdout 0s 5288KB
stdin
abCD AbCd
stdout
abCD = AbCd -> 1