回答編集履歴
2
修正
answer
CHANGED
@@ -202,6 +202,12 @@
|
|
202
202
|
{
|
203
203
|
string input = args[0];
|
204
204
|
|
205
|
+
if(int.Parse(input) == 0)
|
206
|
+
{
|
207
|
+
Console.WriteLine("〇");
|
208
|
+
return;
|
209
|
+
}
|
210
|
+
|
205
211
|
List<string[]> _list = Slice(input.ToCharArray().Select(e => e.ToString()).ToArray());
|
206
212
|
|
207
213
|
for(int i = 0; i < _list.Count; i++)
|
1
修正
answer
CHANGED
@@ -127,4 +127,140 @@
|
|
127
127
|
}
|
128
128
|
}
|
129
129
|
}
|
130
|
+
```
|
131
|
+
# 追記
|
132
|
+
```C#
|
133
|
+
using System;
|
134
|
+
using System.Collections.Generic;
|
135
|
+
using System.Linq;
|
136
|
+
|
137
|
+
namespace Kansuji
|
138
|
+
{
|
139
|
+
class Program
|
140
|
+
{
|
141
|
+
static string Trans(string input)
|
142
|
+
{
|
143
|
+
Dictionary<string, string> dic = new Dictionary<string, string>(){
|
144
|
+
{"0", "〇"},
|
145
|
+
{"1", "一"},
|
146
|
+
{"2", "二"},
|
147
|
+
{"3", "三"},
|
148
|
+
{"4", "四"},
|
149
|
+
{"5", "五"},
|
150
|
+
{"6", "六"},
|
151
|
+
{"7", "七"},
|
152
|
+
{"8", "八"},
|
153
|
+
{"9", "九"},
|
154
|
+
};
|
155
|
+
|
156
|
+
return dic[input];
|
157
|
+
}
|
158
|
+
|
159
|
+
static List<string[]> Slice(string[] input)
|
160
|
+
{
|
161
|
+
input = input.Reverse().ToArray();
|
162
|
+
|
163
|
+
List<string[]> result = new List<string[]>();
|
164
|
+
|
165
|
+
int count = 0;
|
166
|
+
|
167
|
+
while(count + 4 <= input.Length)
|
168
|
+
{
|
169
|
+
string[] _t = new string[4];
|
170
|
+
Array.Copy(input, count, _t, 0, 4);
|
171
|
+
result.Add(_t);
|
172
|
+
count += 4;
|
173
|
+
}
|
174
|
+
|
175
|
+
int rest = input.Length - count;
|
176
|
+
|
177
|
+
if(rest != 0)
|
178
|
+
{
|
179
|
+
string[] _r = new string[4];
|
180
|
+
|
181
|
+
for(int i = 0; i < 4 - rest; i++)
|
182
|
+
{
|
183
|
+
_r[3 - i] = "0";
|
184
|
+
}
|
185
|
+
|
186
|
+
Array.Copy(input, count, _r, 0, rest);
|
187
|
+
result.Add(_r);
|
188
|
+
}
|
189
|
+
|
190
|
+
|
191
|
+
for(int i = 0; i < result.Count; i++)
|
192
|
+
{
|
193
|
+
result[i] = result[i].Reverse().Select(e => Trans(e)).ToArray();
|
194
|
+
}
|
195
|
+
|
196
|
+
result.Reverse();
|
197
|
+
|
198
|
+
return result;
|
199
|
+
}
|
200
|
+
|
201
|
+
static void Main(string[] args)
|
202
|
+
{
|
203
|
+
string input = args[0];
|
204
|
+
|
205
|
+
List<string[]> _list = Slice(input.ToCharArray().Select(e => e.ToString()).ToArray());
|
206
|
+
|
207
|
+
for(int i = 0; i < _list.Count; i++)
|
208
|
+
{
|
209
|
+
string[] _c = _list[i];
|
210
|
+
|
211
|
+
for(int j = 0; j < _c.Length; j++)
|
212
|
+
{
|
213
|
+
string _d = _c[j];
|
214
|
+
|
215
|
+
if(_d == "〇")
|
216
|
+
{
|
217
|
+
_d = "";
|
218
|
+
}
|
219
|
+
else if(_d == "一")
|
220
|
+
{
|
221
|
+
_d = "千百十一"[j].ToString();
|
222
|
+
}
|
223
|
+
else
|
224
|
+
{
|
225
|
+
_d = j < 3 ? _d + "千百十"[j].ToString() : _d;
|
226
|
+
}
|
227
|
+
|
228
|
+
_c[j] = _d;
|
229
|
+
}
|
230
|
+
|
231
|
+
_list[i] = _c;
|
232
|
+
}
|
233
|
+
|
234
|
+
string[] _k = new string[]{ "", "万", "億", "兆" };
|
235
|
+
|
236
|
+
List<string> result = new List<string>();
|
237
|
+
|
238
|
+
_list.Reverse();
|
239
|
+
|
240
|
+
for(int i = 0; i < _list.Count; i++)
|
241
|
+
{
|
242
|
+
string[] arr = _list[i];
|
243
|
+
|
244
|
+
bool next_flag = true;
|
245
|
+
|
246
|
+
foreach(string s in arr)
|
247
|
+
{
|
248
|
+
if(s != "") next_flag = false;
|
249
|
+
}
|
250
|
+
|
251
|
+
if(next_flag) continue;
|
252
|
+
|
253
|
+
result.Add(_k[i]);
|
254
|
+
|
255
|
+
string[] check = arr.Where(e => e != "").ToArray();
|
256
|
+
|
257
|
+
result.Add(check.Length == 1 && check[0] == "千" && i != 0 ? "一千" : string.Join("", arr));
|
258
|
+
}
|
259
|
+
|
260
|
+
result.Reverse();
|
261
|
+
|
262
|
+
Console.WriteLine(string.Join("", result));
|
263
|
+
}
|
264
|
+
}
|
265
|
+
}
|
130
266
|
```
|