質問編集履歴

6

2018/11/18 19:03

投稿

Miyuu_apple38
Miyuu_apple38

スコア12

test CHANGED
File without changes
test CHANGED
@@ -50,7 +50,7 @@
50
50
 
51
51
  Cell c = header.next;
52
52
 
53
- Cell i = i.next
53
+ Cell i = c.next
54
54
 
55
55
 
56
56
 

5

2018/11/18 19:03

投稿

Miyuu_apple38
Miyuu_apple38

スコア12

test CHANGED
File without changes
test CHANGED
File without changes

4

2018/11/18 19:01

投稿

Miyuu_apple38
Miyuu_apple38

スコア12

test CHANGED
File without changes
test CHANGED
@@ -84,4 +84,4 @@
84
84
 
85
85
  ```
86
86
 
87
- 上のように、iというCellをおいて、while文を繰り返すことは可能なのでしょうか?
87
+ 上のように、iというCellをおいてCell 1, Cell 2, ... , Cell 100のように数字の名前のCellをつくって、while文を繰り返すことは可能なのでしょうか?

3

2018/11/18 19:00

投稿

Miyuu_apple38
Miyuu_apple38

スコア12

test CHANGED
File without changes
test CHANGED
@@ -40,7 +40,7 @@
40
40
 
41
41
  ```
42
42
 
43
- 上のコードで実行すると、{0,3,4,1,2}が{0,3,1,2,4}になります。これを繰り返して{0,1,2,3,4}にしたいです。
43
+ 上のコードで実行すると、{0,3,4,1,2}が{0,3,1,2,4}になります。whileの部分を繰り返して{0,1,2,3,4}にしたいです。
44
44
 
45
45
  ```
46
46
 

2

2018/11/18 18:58

投稿

Miyuu_apple38
Miyuu_apple38

スコア12

test CHANGED
File without changes
test CHANGED
@@ -66,7 +66,7 @@
66
66
 
67
67
  }
68
68
 
69
- i = i .next;
69
+ i = i.next;
70
70
 
71
71
  }
72
72
 

1

2018/11/18 18:57

投稿

Miyuu_apple38
Miyuu_apple38

スコア12

test CHANGED
File without changes
test CHANGED
@@ -48,65 +48,31 @@
48
48
 
49
49
 
50
50
 
51
- Cell c1 = header.next;
51
+ Cell c = header.next;
52
52
 
53
- Cell c2 = c1.next;
53
+ Cell i = i.next
54
-
55
- Cell c3 = header.next;
56
-
57
- Cell c4 = c3.next;
58
54
 
59
55
 
60
56
 
61
- while (c4 != end) {
57
+ for (int i=1 ; i<= 100; ++i) {
62
58
 
63
59
 
64
60
 
65
- while (c2 != end) {
61
+ while (i != end) {
66
62
 
63
+ if ( (Integer)c.data > (Integer)i .data ) {
67
64
 
68
-
69
- if ( (Integer)c1.data > (Integer)c2.data ) {
70
-
71
- swap(c1,c2);
65
+ swap(c,i);
72
66
 
73
67
  }
74
68
 
75
-
76
-
77
-
78
-
79
- c1 = c1.next;
69
+ i = i .next;
80
-
81
- c2 = c2.next;
82
70
 
83
71
  }
84
72
 
85
73
 
86
74
 
87
- if ( (Integer)c3.data > (Integer)c4.data ) {
88
-
89
- swap(c3,c4);
90
-
91
- }
92
-
93
-
94
-
95
-
96
-
97
- c3 = c3.next;
98
-
99
- c4 = c4.next;
100
-
101
-
102
-
103
75
  }
104
-
105
-
106
-
107
- \ 同じwhile文を書く...
108
-
109
-
110
76
 
111
77
 
112
78
 
@@ -118,4 +84,4 @@
118
84
 
119
85
  ```
120
86
 
121
- 上のように同じwhile文を何度も書かい、効率的な方法がいろいろ試ましたがわりません。
87
+ 上のように、iというCellをおいて、while文を繰り返すことは可能のでょう