回答編集履歴
2
修正
test
CHANGED
@@ -406,6 +406,18 @@
|
|
406
406
|
|
407
407
|
|
408
408
|
|
409
|
+
if(int.Parse(input) == 0)
|
410
|
+
|
411
|
+
{
|
412
|
+
|
413
|
+
Console.WriteLine("〇");
|
414
|
+
|
415
|
+
return;
|
416
|
+
|
417
|
+
}
|
418
|
+
|
419
|
+
|
420
|
+
|
409
421
|
List<string[]> _list = Slice(input.ToCharArray().Select(e => e.ToString()).ToArray());
|
410
422
|
|
411
423
|
|
1
修正
test
CHANGED
@@ -257,3 +257,275 @@
|
|
257
257
|
}
|
258
258
|
|
259
259
|
```
|
260
|
+
|
261
|
+
# 追記
|
262
|
+
|
263
|
+
```C#
|
264
|
+
|
265
|
+
using System;
|
266
|
+
|
267
|
+
using System.Collections.Generic;
|
268
|
+
|
269
|
+
using System.Linq;
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
namespace Kansuji
|
274
|
+
|
275
|
+
{
|
276
|
+
|
277
|
+
class Program
|
278
|
+
|
279
|
+
{
|
280
|
+
|
281
|
+
static string Trans(string input)
|
282
|
+
|
283
|
+
{
|
284
|
+
|
285
|
+
Dictionary<string, string> dic = new Dictionary<string, string>(){
|
286
|
+
|
287
|
+
{"0", "〇"},
|
288
|
+
|
289
|
+
{"1", "一"},
|
290
|
+
|
291
|
+
{"2", "二"},
|
292
|
+
|
293
|
+
{"3", "三"},
|
294
|
+
|
295
|
+
{"4", "四"},
|
296
|
+
|
297
|
+
{"5", "五"},
|
298
|
+
|
299
|
+
{"6", "六"},
|
300
|
+
|
301
|
+
{"7", "七"},
|
302
|
+
|
303
|
+
{"8", "八"},
|
304
|
+
|
305
|
+
{"9", "九"},
|
306
|
+
|
307
|
+
};
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
return dic[input];
|
312
|
+
|
313
|
+
}
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
static List<string[]> Slice(string[] input)
|
318
|
+
|
319
|
+
{
|
320
|
+
|
321
|
+
input = input.Reverse().ToArray();
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
List<string[]> result = new List<string[]>();
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
int count = 0;
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
while(count + 4 <= input.Length)
|
334
|
+
|
335
|
+
{
|
336
|
+
|
337
|
+
string[] _t = new string[4];
|
338
|
+
|
339
|
+
Array.Copy(input, count, _t, 0, 4);
|
340
|
+
|
341
|
+
result.Add(_t);
|
342
|
+
|
343
|
+
count += 4;
|
344
|
+
|
345
|
+
}
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
int rest = input.Length - count;
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
if(rest != 0)
|
354
|
+
|
355
|
+
{
|
356
|
+
|
357
|
+
string[] _r = new string[4];
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
for(int i = 0; i < 4 - rest; i++)
|
362
|
+
|
363
|
+
{
|
364
|
+
|
365
|
+
_r[3 - i] = "0";
|
366
|
+
|
367
|
+
}
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
Array.Copy(input, count, _r, 0, rest);
|
372
|
+
|
373
|
+
result.Add(_r);
|
374
|
+
|
375
|
+
}
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
for(int i = 0; i < result.Count; i++)
|
382
|
+
|
383
|
+
{
|
384
|
+
|
385
|
+
result[i] = result[i].Reverse().Select(e => Trans(e)).ToArray();
|
386
|
+
|
387
|
+
}
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
result.Reverse();
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
return result;
|
396
|
+
|
397
|
+
}
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
static void Main(string[] args)
|
402
|
+
|
403
|
+
{
|
404
|
+
|
405
|
+
string input = args[0];
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
List<string[]> _list = Slice(input.ToCharArray().Select(e => e.ToString()).ToArray());
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
for(int i = 0; i < _list.Count; i++)
|
414
|
+
|
415
|
+
{
|
416
|
+
|
417
|
+
string[] _c = _list[i];
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
for(int j = 0; j < _c.Length; j++)
|
422
|
+
|
423
|
+
{
|
424
|
+
|
425
|
+
string _d = _c[j];
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
if(_d == "〇")
|
430
|
+
|
431
|
+
{
|
432
|
+
|
433
|
+
_d = "";
|
434
|
+
|
435
|
+
}
|
436
|
+
|
437
|
+
else if(_d == "一")
|
438
|
+
|
439
|
+
{
|
440
|
+
|
441
|
+
_d = "千百十一"[j].ToString();
|
442
|
+
|
443
|
+
}
|
444
|
+
|
445
|
+
else
|
446
|
+
|
447
|
+
{
|
448
|
+
|
449
|
+
_d = j < 3 ? _d + "千百十"[j].ToString() : _d;
|
450
|
+
|
451
|
+
}
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
_c[j] = _d;
|
456
|
+
|
457
|
+
}
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
_list[i] = _c;
|
462
|
+
|
463
|
+
}
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
string[] _k = new string[]{ "", "万", "億", "兆" };
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
List<string> result = new List<string>();
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
_list.Reverse();
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
for(int i = 0; i < _list.Count; i++)
|
480
|
+
|
481
|
+
{
|
482
|
+
|
483
|
+
string[] arr = _list[i];
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
bool next_flag = true;
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
foreach(string s in arr)
|
492
|
+
|
493
|
+
{
|
494
|
+
|
495
|
+
if(s != "") next_flag = false;
|
496
|
+
|
497
|
+
}
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
if(next_flag) continue;
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
result.Add(_k[i]);
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
string[] check = arr.Where(e => e != "").ToArray();
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
result.Add(check.Length == 1 && check[0] == "千" && i != 0 ? "一千" : string.Join("", arr));
|
514
|
+
|
515
|
+
}
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
result.Reverse();
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
Console.WriteLine(string.Join("", result));
|
524
|
+
|
525
|
+
}
|
526
|
+
|
527
|
+
}
|
528
|
+
|
529
|
+
}
|
530
|
+
|
531
|
+
```
|