回答編集履歴
5
d
test
CHANGED
File without changes
|
4
d
test
CHANGED
@@ -63,31 +63,3 @@
|
|
63
63
|
l += 1
|
64
64
|
|
65
65
|
```
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
----
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
for と while の対応
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
```python
|
78
|
-
|
79
|
-
for i in range(10):
|
80
|
-
|
81
|
-
print(i)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
# while で書き換えると以下と同じ
|
86
|
-
|
87
|
-
i = 0
|
88
|
-
|
89
|
-
for i in range(10):
|
90
|
-
|
91
|
-
print(i)
|
92
|
-
|
93
|
-
```
|
3
d
test
CHANGED
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
書き換え可能です。
|
40
40
|
|
41
|
-
while で書き換えた場合
|
41
|
+
質問の問題の解答を while で書き換えた場合
|
42
42
|
|
43
43
|
|
44
44
|
|
@@ -66,6 +66,10 @@
|
|
66
66
|
|
67
67
|
|
68
68
|
|
69
|
+
----
|
70
|
+
|
71
|
+
|
72
|
+
|
69
73
|
for と while の対応
|
70
74
|
|
71
75
|
|
2
g
test
CHANGED
@@ -25,3 +25,65 @@
|
|
25
25
|
print(a, b, c)
|
26
26
|
|
27
27
|
```
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
## 追記
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
> for(1,9998)とはwhileで書き換え可能ですか?
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
書き換え可能です。
|
40
|
+
|
41
|
+
while で書き換えた場合
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
```python
|
46
|
+
|
47
|
+
l = 1
|
48
|
+
|
49
|
+
while l < 9998:
|
50
|
+
|
51
|
+
# l = 1, 2, ..., 9997 までループ
|
52
|
+
|
53
|
+
a, b, c = l, l + 1, l + 2 # 短い順に3辺の長さ
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
if a ** 2 + b ** 2 == c ** 2:
|
58
|
+
|
59
|
+
print(a, b, c)
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
l += 1
|
64
|
+
|
65
|
+
```
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
for と while の対応
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
```python
|
74
|
+
|
75
|
+
for i in range(10):
|
76
|
+
|
77
|
+
print(i)
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
# while で書き換えると以下と同じ
|
82
|
+
|
83
|
+
i = 0
|
84
|
+
|
85
|
+
for i in range(10):
|
86
|
+
|
87
|
+
print(i)
|
88
|
+
|
89
|
+
```
|
1
d
test
CHANGED
@@ -16,12 +16,12 @@
|
|
16
16
|
|
17
17
|
# l = 1, 2, ..., 9997 までループ
|
18
18
|
|
19
|
-
|
19
|
+
a, b, c = l, l + 1, l + 2 # 短い順に3辺の長さ
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
if
|
23
|
+
if a ** 2 + b ** 2 == c ** 2:
|
24
24
|
|
25
|
-
print(
|
25
|
+
print(a, b, c)
|
26
26
|
|
27
27
|
```
|