回答編集履歴
3
追加
test
CHANGED
@@ -43,3 +43,47 @@
|
|
43
43
|
}
|
44
44
|
|
45
45
|
```
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
do-while は for に纏めれば小さくなりますね.
|
50
|
+
|
51
|
+
```c
|
52
|
+
|
53
|
+
#include <stdio.h>
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
#define N 3 /*人数*/
|
58
|
+
|
59
|
+
#define M 100 /*最大枚数*/
|
60
|
+
|
61
|
+
#define C 'a' /*カード(オフセット)*/
|
62
|
+
|
63
|
+
#define P 'A' /*参加者(オフセット)*/
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
int main(int argc, char *argv[]) {
|
68
|
+
|
69
|
+
int i, top[N]={0};
|
70
|
+
|
71
|
+
char card, S[N][M+1];
|
72
|
+
|
73
|
+
//入力
|
74
|
+
|
75
|
+
for(i=0;i<N;i++) scanf("%s", S[i]);
|
76
|
+
|
77
|
+
//勝負
|
78
|
+
|
79
|
+
for(card=C; card!='\0'; card=S[i][top[i]++]) i = card - C;
|
80
|
+
|
81
|
+
//出力
|
82
|
+
|
83
|
+
printf("%c\n", i + P);
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
```
|
2
コードを読み易く(?)
test
CHANGED
@@ -6,33 +6,39 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
in
|
9
|
+
#define N 3 /*人数*/
|
10
10
|
|
11
|
-
|
11
|
+
#define M 100 /*最大枚数*/
|
12
12
|
|
13
|
-
|
13
|
+
#define C 'a' /*カード(オフセット)*/
|
14
|
+
|
15
|
+
#define P 'A' /*参加者(オフセット)*/
|
14
16
|
|
15
17
|
|
16
18
|
|
17
|
-
|
19
|
+
int main(int argc, char *argv[]) {
|
18
20
|
|
19
|
-
|
21
|
+
int i, top[N]={0};
|
20
22
|
|
21
|
-
|
23
|
+
char card, S[N][M+1];
|
22
24
|
|
23
25
|
|
24
26
|
|
27
|
+
for(i=0;i<N;i++) scanf("%s", S[i]);
|
28
|
+
|
29
|
+
|
30
|
+
|
25
|
-
c =
|
31
|
+
card = C;
|
26
32
|
|
27
33
|
do {
|
28
34
|
|
29
|
-
i = c -
|
35
|
+
i = card - C;
|
30
36
|
|
31
|
-
c = S[i][
|
37
|
+
card = S[i][top[i]++];
|
32
38
|
|
33
|
-
} while(c != '\0');
|
39
|
+
} while(card != '\0');
|
34
40
|
|
35
|
-
printf("%c\n", i+
|
41
|
+
printf("%c\n", i + P);
|
36
42
|
|
37
43
|
}
|
38
44
|
|
1
char 変数があったほうが分かり易い?
test
CHANGED
@@ -8,9 +8,9 @@
|
|
8
8
|
|
9
9
|
int main(int argc, char *argv[]) {
|
10
10
|
|
11
|
-
|
11
|
+
int i, n[3]={0};
|
12
12
|
|
13
|
-
|
13
|
+
char c, S[3][101];
|
14
14
|
|
15
15
|
|
16
16
|
|
@@ -22,15 +22,15 @@
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
-
|
25
|
+
c = 'a';
|
26
26
|
|
27
27
|
do {
|
28
28
|
|
29
|
-
i =
|
29
|
+
i = c - 'a';
|
30
30
|
|
31
|
-
|
31
|
+
c = S[i][n[i]++];
|
32
32
|
|
33
|
-
} while(
|
33
|
+
} while(c != '\0');
|
34
34
|
|
35
35
|
printf("%c\n", i+'A');
|
36
36
|
|