質問編集履歴
2
6桁の数字が違っていた
test
CHANGED
File without changes
|
test
CHANGED
@@ -112,7 +112,7 @@
|
|
112
112
|
|
113
113
|
int nmax=100;
|
114
114
|
|
115
|
-
int x=1
|
115
|
+
int x=123456;
|
116
116
|
|
117
117
|
for (n=1;n<=nmax;n++){
|
118
118
|
|
@@ -178,7 +178,7 @@
|
|
178
178
|
|
179
179
|
int nmax=100;
|
180
180
|
|
181
|
-
int x=
|
181
|
+
int x=123456;
|
182
182
|
|
183
183
|
for (n=1;n<=nmax;n++){
|
184
184
|
|
1
C
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,90 +12,158 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
+
|
16
|
+
|
17
|
+
```C
|
18
|
+
|
19
|
+
#include <stdio.h>
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
//problem 1
|
24
|
+
|
25
|
+
void ao3(int *x){
|
26
|
+
|
27
|
+
int tmp;
|
28
|
+
|
29
|
+
if (x[0] > x[1]){
|
30
|
+
|
31
|
+
tmp=x[0];
|
32
|
+
|
33
|
+
x[0]=x[1];
|
34
|
+
|
35
|
+
x[1]=tmp;
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
if (x[1] > x[2]){
|
40
|
+
|
41
|
+
tmp=x[1];
|
42
|
+
|
43
|
+
x[1]=x[2];
|
44
|
+
|
45
|
+
x[2]=tmp;
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
if (x[0] > x[1]){
|
50
|
+
|
51
|
+
tmp=x[0];
|
52
|
+
|
53
|
+
x[0]=x[1];
|
54
|
+
|
55
|
+
x[1]=tmp;
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
int main(void){
|
62
|
+
|
63
|
+
int a[3]={3,2,1};
|
64
|
+
|
65
|
+
printf("%d %d %d\n",a[0],a[1],a[2]);
|
66
|
+
|
67
|
+
ao3(a);
|
68
|
+
|
69
|
+
printf("%d %d %d\n",a[0],a[1],a[2]);
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
return 0;
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
// problem 2
|
80
|
+
|
81
|
+
void lcg()
|
82
|
+
|
83
|
+
{
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
int main(void){
|
100
|
+
|
101
|
+
int n;
|
102
|
+
|
103
|
+
int a[3]={4,5,1}; ao3(a);
|
104
|
+
|
105
|
+
for (n=0;n<3;n++){
|
106
|
+
|
107
|
+
printf("%d ",a[n]);
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
puts("");
|
112
|
+
|
113
|
+
int nmax=100;
|
114
|
+
|
115
|
+
int x=191234;
|
116
|
+
|
117
|
+
for (n=1;n<=nmax;n++){
|
118
|
+
|
119
|
+
lcg(&x);
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
printf("%d\n",x);
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
return 0;
|
128
|
+
|
129
|
+
}
|
130
|
+
|
15
131
|
```
|
16
132
|
|
17
|
-
|
133
|
+
|
18
|
-
|
19
|
-
|
20
|
-
|
134
|
+
|
21
|
-
//problem
|
135
|
+
### //problem 2から下のvoid lag()に何を書けば計算できるか分からない状態です。
|
136
|
+
|
137
|
+
|
138
|
+
|
22
|
-
|
139
|
+
```C
|
140
|
+
|
23
|
-
void
|
141
|
+
void lcg()
|
24
|
-
|
142
|
+
|
25
|
-
|
143
|
+
{
|
26
|
-
|
27
|
-
|
144
|
+
|
28
|
-
|
29
|
-
|
145
|
+
|
30
|
-
|
31
|
-
|
146
|
+
|
32
|
-
|
33
|
-
|
147
|
+
|
34
|
-
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
35
|
-
|
155
|
+
}
|
156
|
+
|
36
|
-
|
157
|
+
```
|
158
|
+
|
159
|
+
|
160
|
+
|
37
|
-
|
161
|
+
以下の記述はint x=に6桁の数字を入れた時のとしたとき、x100の値の計算になります。
|
38
|
-
|
162
|
+
|
39
|
-
|
163
|
+
```C
|
40
|
-
|
41
|
-
x[1]=x[2];
|
42
|
-
|
43
|
-
x[2]=tmp;
|
44
|
-
|
45
|
-
}
|
46
|
-
|
47
|
-
if (x[0] > x[1]){
|
48
|
-
|
49
|
-
tmp=x[0];
|
50
|
-
|
51
|
-
x[0]=x[1];
|
52
|
-
|
53
|
-
x[1]=tmp;
|
54
|
-
|
55
|
-
}
|
56
|
-
|
57
|
-
}
|
58
164
|
|
59
165
|
int main(void){
|
60
166
|
|
61
|
-
int a[3]={3,2,1};
|
62
|
-
|
63
|
-
printf("%d %d %d\n",a[0],a[1],a[2]);
|
64
|
-
|
65
|
-
ao3(a);
|
66
|
-
|
67
|
-
printf("%d %d %d\n",a[0],a[1],a[2]);
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
return 0;
|
72
|
-
|
73
|
-
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
// problem 2
|
78
|
-
|
79
|
-
void lcg()
|
80
|
-
|
81
|
-
{
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
}
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
int main(void){
|
98
|
-
|
99
167
|
int n;
|
100
168
|
|
101
169
|
int a[3]={4,5,1}; ao3(a);
|
@@ -110,7 +178,7 @@
|
|
110
178
|
|
111
179
|
int nmax=100;
|
112
180
|
|
113
|
-
int x=
|
181
|
+
int x=884893;
|
114
182
|
|
115
183
|
for (n=1;n<=nmax;n++){
|
116
184
|
|
@@ -130,72 +198,6 @@
|
|
130
198
|
|
131
199
|
|
132
200
|
|
133
|
-
### //problem 2から下のvoid lag()に何を書けば計算できるか分からない状態です。
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
```
|
138
|
-
|
139
|
-
void lcg()
|
140
|
-
|
141
|
-
{
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
|
-
```
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
以下の記述はint x=に6桁の数字を入れた時のとしたとき、x100の値の計算になります。
|
160
|
-
|
161
|
-
```
|
162
|
-
|
163
|
-
int main(void){
|
164
|
-
|
165
|
-
int n;
|
166
|
-
|
167
|
-
int a[3]={4,5,1}; ao3(a);
|
168
|
-
|
169
|
-
for (n=0;n<3;n++){
|
170
|
-
|
171
|
-
printf("%d ",a[n]);
|
172
|
-
|
173
|
-
}
|
174
|
-
|
175
|
-
puts("");
|
176
|
-
|
177
|
-
int nmax=100;
|
178
|
-
|
179
|
-
int x=884893;
|
180
|
-
|
181
|
-
for (n=1;n<=nmax;n++){
|
182
|
-
|
183
|
-
lcg(&x);
|
184
|
-
|
185
|
-
}
|
186
|
-
|
187
|
-
printf("%d\n",x);
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
return 0;
|
192
|
-
|
193
|
-
}
|
194
|
-
|
195
|
-
```
|
196
|
-
|
197
|
-
|
198
|
-
|
199
201
|
|
200
202
|
|
201
203
|
|