質問編集履歴
1
コードをインデント
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,270 +40,274 @@
|
|
40
40
|
|
41
41
|
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
using System
|
46
|
-
|
47
|
-
using System.Co
|
48
|
-
|
49
|
-
using System.
|
50
|
-
|
51
|
-
using System.D
|
52
|
-
|
53
|
-
using System.
|
54
|
-
|
55
|
-
using System.
|
56
|
-
|
57
|
-
using System.T
|
58
|
-
|
59
|
-
using System.
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
is
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
t
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
is
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
}
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
43
|
+
|
44
|
+
|
45
|
+
> using System;
|
46
|
+
|
47
|
+
> using System.Collections.Generic;
|
48
|
+
|
49
|
+
> using System.ComponentModel;
|
50
|
+
|
51
|
+
> using System.Data;
|
52
|
+
|
53
|
+
> using System.Drawing;
|
54
|
+
|
55
|
+
> using System.Linq;
|
56
|
+
|
57
|
+
> using System.Text;
|
58
|
+
|
59
|
+
> using System.Threading.Tasks;
|
60
|
+
|
61
|
+
> using System.Windows.Forms;
|
62
|
+
|
63
|
+
>
|
64
|
+
|
65
|
+
> namespace WindowsFormsApp1
|
66
|
+
|
67
|
+
> {
|
68
|
+
|
69
|
+
> public partial class Form1 : Form
|
70
|
+
|
71
|
+
> {
|
72
|
+
|
73
|
+
>
|
74
|
+
|
75
|
+
> public Form1()
|
76
|
+
|
77
|
+
> {
|
78
|
+
|
79
|
+
> InitializeComponent();
|
80
|
+
|
81
|
+
> }
|
82
|
+
|
83
|
+
>
|
84
|
+
|
85
|
+
> bool isFirst = true;
|
86
|
+
|
87
|
+
> double val1 = 0;
|
88
|
+
|
89
|
+
>
|
90
|
+
|
91
|
+
> private void Form1_Load(object sender, EventArgs e)
|
92
|
+
|
93
|
+
> {
|
94
|
+
|
95
|
+
>
|
96
|
+
|
97
|
+
> }
|
98
|
+
|
99
|
+
>
|
100
|
+
|
101
|
+
> private void btnNumber_Click(object sender, EventArgs e)
|
102
|
+
|
103
|
+
> {
|
104
|
+
|
105
|
+
> if (isFirst)
|
106
|
+
|
107
|
+
> {
|
108
|
+
|
109
|
+
> txtDisplay.Text = "";
|
110
|
+
|
111
|
+
> isFirst = false;
|
112
|
+
|
113
|
+
> }
|
114
|
+
|
115
|
+
> String text = txtDisplay.Text + ((Button)sender).Text;
|
116
|
+
|
117
|
+
>
|
118
|
+
|
119
|
+
> //文字列 -> 数値
|
120
|
+
|
121
|
+
> double d = Convert.ToDouble(text);
|
122
|
+
|
123
|
+
>
|
124
|
+
|
125
|
+
> //数値 -> 文字列(先頭の0が消える)
|
126
|
+
|
127
|
+
> String text2 = d.ToString();
|
128
|
+
|
129
|
+
> txtDisplay.Text = text2;
|
130
|
+
|
131
|
+
> }
|
132
|
+
|
133
|
+
>
|
134
|
+
|
135
|
+
> enum sign { blank, ADD, SUB, MUL, DIV };
|
136
|
+
|
137
|
+
> sign exec = sign.blank;
|
138
|
+
|
139
|
+
>
|
140
|
+
|
141
|
+
> //クリア
|
142
|
+
|
143
|
+
> private void button_clear_Click(object sender, EventArgs e)
|
144
|
+
|
145
|
+
> {
|
146
|
+
|
147
|
+
> exec = sign.blank;
|
148
|
+
|
149
|
+
> txtDisplay.Text = "0";
|
150
|
+
|
151
|
+
> val1 = 0;
|
152
|
+
|
153
|
+
> isFirst = true;
|
154
|
+
|
155
|
+
> }
|
156
|
+
|
157
|
+
>
|
158
|
+
|
159
|
+
> //小数点
|
160
|
+
|
161
|
+
> private void button_dot_Click(object sender, EventArgs e)
|
162
|
+
|
163
|
+
> {
|
164
|
+
|
165
|
+
> //小数点の重複チェック
|
166
|
+
|
167
|
+
> if(txtDisplay.Text.IndexOf(".") >= 1)
|
168
|
+
|
169
|
+
> {
|
170
|
+
|
171
|
+
> //すでに小数点がある
|
172
|
+
|
173
|
+
> return;
|
174
|
+
|
175
|
+
> }
|
176
|
+
|
177
|
+
> txtDisplay.Text = txtDisplay.Text + ".";
|
178
|
+
|
179
|
+
>
|
180
|
+
|
181
|
+
> }
|
182
|
+
|
183
|
+
>
|
184
|
+
|
185
|
+
> //足し算。
|
186
|
+
|
187
|
+
> private void button_tasu_Click(object sender, EventArgs e)
|
188
|
+
|
189
|
+
> {
|
190
|
+
|
191
|
+
> if (!isFirst) calc();
|
192
|
+
|
193
|
+
> exec = sign.ADD;
|
194
|
+
|
195
|
+
> }
|
196
|
+
|
197
|
+
>
|
198
|
+
|
199
|
+
> //引き算。
|
200
|
+
|
201
|
+
> private void button_hiku_Click(object sender, EventArgs e)
|
202
|
+
|
203
|
+
> {
|
204
|
+
|
205
|
+
> if (!isFirst) calc();
|
206
|
+
|
207
|
+
> exec = sign.SUB;
|
208
|
+
|
209
|
+
> }
|
210
|
+
|
211
|
+
>
|
212
|
+
|
213
|
+
> //掛け算。
|
214
|
+
|
215
|
+
> private void button_kakuru_Click(object sender, EventArgs e)
|
216
|
+
|
217
|
+
> {
|
218
|
+
|
219
|
+
> if (!isFirst) calc();
|
220
|
+
|
221
|
+
> exec = sign.MUL;
|
222
|
+
|
223
|
+
> }
|
224
|
+
|
225
|
+
>
|
226
|
+
|
227
|
+
> //割り算。
|
228
|
+
|
229
|
+
> private void button_waru_Click(object sender, EventArgs e)
|
230
|
+
|
231
|
+
> {
|
232
|
+
|
233
|
+
> if (!isFirst) calc();
|
234
|
+
|
235
|
+
> exec = sign.DIV;
|
236
|
+
|
237
|
+
> }
|
238
|
+
|
239
|
+
>
|
240
|
+
|
241
|
+
> //イコール。
|
242
|
+
|
243
|
+
> private void button_wa_Click(object sender, EventArgs e)
|
244
|
+
|
245
|
+
> {
|
246
|
+
|
247
|
+
> calc();
|
248
|
+
|
249
|
+
> }
|
250
|
+
|
251
|
+
>
|
252
|
+
|
253
|
+
> private void calc()
|
254
|
+
|
255
|
+
> {
|
256
|
+
|
257
|
+
> double val2 = Convert.ToDouble(txtDisplay.Text);
|
258
|
+
|
259
|
+
> switch (exec)
|
260
|
+
|
261
|
+
> {
|
262
|
+
|
263
|
+
> case sign.ADD:
|
264
|
+
|
265
|
+
> val1 += val2;
|
266
|
+
|
267
|
+
> break;
|
268
|
+
|
269
|
+
> case sign.SUB:
|
270
|
+
|
271
|
+
> val1 -= val2;
|
272
|
+
|
273
|
+
> break;
|
274
|
+
|
275
|
+
> case sign.MUL:
|
276
|
+
|
277
|
+
> val1 *= val2;
|
278
|
+
|
279
|
+
> break;
|
280
|
+
|
281
|
+
> case sign.DIV:
|
282
|
+
|
283
|
+
> val1 /= val2;
|
284
|
+
|
285
|
+
> break;
|
286
|
+
|
287
|
+
> default:
|
288
|
+
|
289
|
+
> val1 = val2;
|
290
|
+
|
291
|
+
> break;
|
292
|
+
|
293
|
+
> }
|
294
|
+
|
295
|
+
>
|
296
|
+
|
297
|
+
> double result = Math.Truncate(val1 * 100.0) / 100.0;
|
298
|
+
|
299
|
+
>
|
300
|
+
|
301
|
+
> txtDisplay.Text = result.ToString();
|
302
|
+
|
303
|
+
> isFirst = true;
|
304
|
+
|
305
|
+
> }
|
306
|
+
|
307
|
+
> }
|
308
|
+
|
309
|
+
>
|
310
|
+
|
311
|
+
> }
|
312
|
+
|
313
|
+
```
|