teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

ソース追記

2018/12/13 11:17

投稿

cateye
cateye

スコア6851

answer CHANGED
@@ -30,4 +30,31 @@
30
30
  return 0;
31
31
  }
32
32
  ```
33
- 勘違いか^^;
33
+ 勘違いか^^;
34
+
35
+ 「結果」
36
+ usr~/test/c % ./a.out
37
+ 点数を入力してください:100
38
+ 点数は100点です
39
+ usr~/test/c % ./a.out
40
+ 点数を入力してください:200
41
+ 点数は100点です
42
+ usr~/test/c % ./a.out
43
+ 点数を入力してください:66
44
+ 点数は66点です
45
+ usr~/test/c % cat s1.c
46
+ ```c
47
+ #include <stdio.h>
48
+
49
+ int main(void)
50
+ {
51
+ int score;
52
+ printf("点数を入力してください:");
53
+ scanf("%d", &score);
54
+ if (score > 100)
55
+ score = 100;
56
+ printf("点数は%d点です\n", score);
57
+ return 0;
58
+ }
59
+ ```
60
+ usr~/test/c %

1

ソース追記

2018/12/13 11:17

投稿

cateye
cateye

スコア6851

answer CHANGED
@@ -1,1 +1,33 @@
1
- "%d , %d" → "%d,%d"・・・空白待ちになっていませんか?
1
+ "%d , %d" → "%d,%d"・・・空白待ちになっていませんか?
2
+ う〜〜ん・・・動くようだなぁ
3
+ usr~/test/c % ./a.out
4
+ 2 , 3
5
+ a=2 b=3
6
+ usr~/test/c % ./a.out
7
+ 2,3
8
+ a=2 b=3
9
+ usr~/test/c % ./a.out
10
+ 2 , 5
11
+ a=2 b=5
12
+ usr~/test/c % ./a.out
13
+ 2
14
+ ,
15
+ 2
16
+ a=2 b=2
17
+ ```c
18
+ usr~/test/c % cat s1.c
19
+ #include <stdio.h>
20
+
21
+ int main()
22
+ {
23
+ int a, b;
24
+
25
+ if(scanf("%d , %d",&a, &b)!=2){
26
+ return 1;
27
+ }
28
+ printf("a=%d b=%d\n", a, b);
29
+
30
+ return 0;
31
+ }
32
+ ```
33
+ 勘違いか^^;