回答編集履歴

4

バグ修正

2022/11/04 03:55

投稿

jimbe
jimbe

スコア12659

test CHANGED
@@ -4,7 +4,7 @@
4
4
  for(char *d=s; *d=*s++; d+=*d=='?'?0:1);
5
5
  }
6
6
  int compare(char *a, char *b) {
7
- while(*a && *b) if(*a++!=*b++) return 1;
7
+ while(*a || *b) if(*a++!=*b++) return 1;
8
8
  return 0;
9
9
  }
10
10
  int main(void) {

3

極微修正

2022/11/04 03:45

投稿

jimbe
jimbe

スコア12659

test CHANGED
@@ -7,7 +7,7 @@
7
7
  while(*a && *b) if(*a++!=*b++) return 1;
8
8
  return 0;
9
9
  }
10
- int main(void){
10
+ int main(void) {
11
11
  char a[30+1], b[30+1];
12
12
  scanf("%s %s", a, b);
13
13
  normalize(a);

2

strcmp を置き換え

2022/11/03 14:12

投稿

jimbe
jimbe

スコア12659

test CHANGED
@@ -1,14 +1,17 @@
1
1
  ```c
2
2
  #include <stdio.h>
3
- #include <string.h>
4
3
  void normalize(char *s) {
5
4
  for(char *d=s; *d=*s++; d+=*d=='?'?0:1);
5
+ }
6
+ int compare(char *a, char *b) {
7
+ while(*a && *b) if(*a++!=*b++) return 1;
8
+ return 0;
6
9
  }
7
10
  int main(void){
8
11
  char a[30+1], b[30+1];
9
12
  scanf("%s %s", a, b);
10
13
  normalize(a);
11
14
  normalize(b);
12
- printf("%s\n", strcmp(a,b)?"Different":"Same");
15
+ printf("%s\n", compare(a,b)?"Different":"Same");
13
16
  }
14
17
  ```

1

修正

2022/11/03 13:39

投稿

jimbe
jimbe

スコア12659

test CHANGED
@@ -6,8 +6,7 @@
6
6
  }
7
7
  int main(void){
8
8
  char a[30+1], b[30+1];
9
- scanf("%s", a);
9
+ scanf("%s %s", a, b);
10
- scanf("%s", b);
11
10
  normalize(a);
12
11
  normalize(b);
13
12
  printf("%s\n", strcmp(a,b)?"Different":"Same");