回答編集履歴
3
追加
test
CHANGED
@@ -80,7 +80,7 @@
|
|
80
80
|
|
81
81
|
|
82
82
|
|
83
|
-
return
|
83
|
+
return string;
|
84
84
|
|
85
85
|
}
|
86
86
|
|
@@ -94,7 +94,7 @@
|
|
94
94
|
|
95
95
|
|
96
96
|
|
97
|
-
return
|
97
|
+
return string;
|
98
98
|
|
99
99
|
}
|
100
100
|
|
@@ -115,3 +115,123 @@
|
|
115
115
|
ズレるのが気持ち悪いので、`char tens[10][8] = {"","on",`にしたけど、
|
116
116
|
|
117
117
|
元のままがよいなら、`tens[te]`を全部`tens[te-1]`に。
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
---
|
122
|
+
|
123
|
+
もう少しいじるなら
|
124
|
+
|
125
|
+
```C
|
126
|
+
|
127
|
+
#include <stdlib.h>//malloc
|
128
|
+
|
129
|
+
#include <string.h>//strcpy
|
130
|
+
|
131
|
+
#include <stdio.h>//sprintf
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
char* getTurkishNumber(unsigned int n)
|
136
|
+
|
137
|
+
{
|
138
|
+
|
139
|
+
char *string;
|
140
|
+
|
141
|
+
char *unit[10] = {
|
142
|
+
|
143
|
+
"sıfır",
|
144
|
+
|
145
|
+
"bir",
|
146
|
+
|
147
|
+
"iki",
|
148
|
+
|
149
|
+
"üç",
|
150
|
+
|
151
|
+
"dört",
|
152
|
+
|
153
|
+
"beş",
|
154
|
+
|
155
|
+
"altı",
|
156
|
+
|
157
|
+
"yedi",
|
158
|
+
|
159
|
+
"sekiz",
|
160
|
+
|
161
|
+
"dokuz",
|
162
|
+
|
163
|
+
};
|
164
|
+
|
165
|
+
char *tens[10] = {
|
166
|
+
|
167
|
+
"",
|
168
|
+
|
169
|
+
"on",
|
170
|
+
|
171
|
+
"yirmi",
|
172
|
+
|
173
|
+
"otuz",
|
174
|
+
|
175
|
+
"kırk",
|
176
|
+
|
177
|
+
"elli",
|
178
|
+
|
179
|
+
"altmış",
|
180
|
+
|
181
|
+
"yetmiş",
|
182
|
+
|
183
|
+
"seksen",
|
184
|
+
|
185
|
+
"doksan",
|
186
|
+
|
187
|
+
};
|
188
|
+
|
189
|
+
int te = n /10 %10, un = n % 10;
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
if(te == 0)
|
194
|
+
|
195
|
+
{
|
196
|
+
|
197
|
+
string = malloc(strlen(unit[un])+1);
|
198
|
+
|
199
|
+
strcpy(string, unit[un]);
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
return string;
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
if(un == 0)
|
210
|
+
|
211
|
+
{
|
212
|
+
|
213
|
+
string = malloc(strlen(tens[te])+1);
|
214
|
+
|
215
|
+
strcpy(string, tens[te]);
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
return string;
|
220
|
+
|
221
|
+
}
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
string = malloc(strlen(tens[te])+1+strlen(unit[un])+1);
|
226
|
+
|
227
|
+
sprintf(string,"%s %s",tens[te],unit[un]);
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
return string;
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
```
|
236
|
+
|
237
|
+
とか。
|
2
修正
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
{
|
20
20
|
|
21
|
-
char* string = malloc(1
|
21
|
+
char* string = malloc(14);
|
22
22
|
|
23
23
|
char unit[10][7] = {
|
24
24
|
|
@@ -68,7 +68,7 @@
|
|
68
68
|
|
69
69
|
};
|
70
70
|
|
71
|
-
int te = n /10, un = n % 10;
|
71
|
+
int te = n /10 %10, un = n % 10;
|
72
72
|
|
73
73
|
|
74
74
|
|
1
修正
test
CHANGED
@@ -100,11 +100,7 @@
|
|
100
100
|
|
101
101
|
|
102
102
|
|
103
|
-
strcpy(string, tens[te]);
|
104
|
-
|
105
|
-
s
|
103
|
+
sprintf(string,"%s %s",tens[te],unit[un]);
|
106
|
-
|
107
|
-
strcat(string, unit[un]);
|
108
104
|
|
109
105
|
|
110
106
|
|
@@ -119,9 +115,3 @@
|
|
119
115
|
ズレるのが気持ち悪いので、`char tens[10][8] = {"","on",`にしたけど、
|
120
116
|
|
121
117
|
元のままがよいなら、`tens[te]`を全部`tens[te-1]`に。
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
最後の、`strcpy`と`strcat`は、三つまとめてこれでも可
|
126
|
-
|
127
|
-
`sprintf(string,"%s %s",tens[te],unit[un]);`
|