質問編集履歴

1

ソースコードの引用の仕方を間違えていた

2019/05/16 16:28

投稿

big000
big000

スコア18

test CHANGED
File without changes
test CHANGED
@@ -24,6 +24,10 @@
24
24
 
25
25
 
26
26
 
27
+
28
+
29
+ ```
30
+
27
31
  /*main.c*/
28
32
 
29
33
  #include<stdio.h>
@@ -52,7 +56,9 @@
52
56
 
53
57
 
54
58
 
55
- ______________________________________________________
59
+ ```
60
+
61
+ ```
56
62
 
57
63
  /*mys.h 自分の手を入力するところ*/
58
64
 
@@ -92,109 +98,129 @@
92
98
 
93
99
 
94
100
 
101
+ ```
102
+
103
+ ```
104
+
105
+ /*comp.h コンピュータの手*/
106
+
107
+ #ifndef COMP
108
+
109
+ #define COMP
110
+
111
+
112
+
113
+ extern int b;
114
+
115
+ int random();
116
+
117
+ #endif COMP
118
+
119
+
120
+
121
+
122
+
123
+ /*comp.c*/
124
+
125
+ #include"comp.h"
126
+
127
+ #include<time.h>
128
+
129
+ #include<stdlib.h>
130
+
131
+ #include<stdio.h>
132
+
133
+
134
+
135
+ int b;
136
+
137
+ int random() {
138
+
139
+ srand((unsigned)time(NULL));
140
+
141
+ b= rand() % 1 + 3;
142
+
143
+ return b;
144
+
145
+ }
146
+
147
+ ```
148
+
149
+ ```
150
+
151
+ /*iff.h勝敗の判定をするところ*/
152
+
153
+ #ifndef IFF_H
154
+
155
+ #define IFF_H
156
+
157
+
158
+
159
+ int battle (int, int);
160
+
161
+
162
+
163
+ #endif IFF_H
164
+
165
+
166
+
167
+ /*iff.c*/
168
+
169
+ #include"iff.h"
170
+
171
+ #include<stdio.h>
172
+
173
+ #include"comp.h"
174
+
175
+ #include"mys.h"
176
+
177
+
178
+
179
+ int battle()
180
+
181
+ {
182
+
183
+ if (a == b) {
184
+
185
+ printf("あいこです");
186
+
187
+ return 1;
188
+
189
+ }
190
+
191
+ else if ((a == 1 && b == 2) |(a == 2 && b == 3) |(a == 3 && b == 1)) {
192
+
193
+ printf("あなたの勝ちです");
194
+
195
+ return 0;
196
+
197
+ }
198
+
199
+ else{
200
+
201
+ printf("あなたの負けです");
202
+
203
+ return 0;
204
+
205
+ }
206
+
207
+ }
208
+
209
+ ```
210
+
211
+
212
+
95
213
  ______________________________________________________________
96
214
 
97
- /*comp.h コンピュータの手*/
215
+
98
-
99
- #ifndef COMP
216
+
100
-
101
- #define COMP
217
+
102
-
103
-
104
-
105
- extern int b;
106
-
107
- int random();
108
-
109
- #endif COMP
110
-
111
-
112
-
113
-
114
-
115
- /*comp.c*/
116
-
117
- #include"comp.h"
118
-
119
- #include<time.h>
120
-
121
- #include<stdlib.h>
122
-
123
- #include<stdio.h>
124
-
125
-
126
-
127
- int b;
128
-
129
- int random() {
130
-
131
- srand((unsigned)time(NULL));
132
-
133
- b= rand() % 1 + 3;
134
-
135
- return b;
136
-
137
- }
138
218
 
139
219
  ______________________________________________________________
140
220
 
141
- /*iff.h勝敗の判定をするところ*/
221
+
142
-
143
- #ifndef IFF_H
222
+
144
-
145
- #define IFF_H
223
+
146
-
147
-
148
-
149
- int battle (int, int);
150
-
151
-
152
-
153
- #endif IFF_H
154
-
155
-
156
-
157
- /*iff.c*/
158
-
159
- #include"iff.h"
160
-
161
- #include<stdio.h>
162
-
163
- #include"comp.h"
164
-
165
- #include"mys.h"
166
-
167
-
168
-
169
- int battle()
170
-
171
- {
172
-
173
- if (a == b) {
174
-
175
- printf("あいこです");
176
-
177
- return 1;
178
-
179
- }
180
-
181
- else if ((a == 1 && b == 2) |(a == 2 && b == 3) |(a == 3 && b == 1)) {
182
-
183
- printf("あなたの勝ちです");
184
-
185
- return 0;
186
-
187
- }
188
-
189
- else{
190
-
191
- printf("あなたの負けです");
192
-
193
- return 0;
194
-
195
- }
196
-
197
- }
198
224
 
199
225
 
200
226
 
@@ -210,6 +236,10 @@
210
236
 
211
237
  エラーはなくなったが、論理式がおかしいのか、ファイル分割の仕方がおかしいのか、関数の使い方がおかしいのか分からなかった。
212
238
 
239
+ scanfで、戻り値が無視されている、という警告があったので、
240
+
241
+ extern やグローバル変数の使い方が違うのかと思ったが、よくわからなかった。
242
+
213
243
 
214
244
 
215
245
  ### 補足情報(FW/ツールのバージョンなど)