回答編集履歴
2
書き直したコードを追加
answer
CHANGED
@@ -17,4 +17,43 @@
|
|
17
17
|
int c;
|
18
18
|
while ((c = getchar()) != EOF) putchar(t[c]);
|
19
19
|
}
|
20
|
+
```
|
21
|
+
**追記**
|
22
|
+
こう書けば参考になるのかな。
|
23
|
+
```C
|
24
|
+
#include <stdio.h> // getchar, putchar
|
25
|
+
#include <string.h> // strlen
|
26
|
+
|
27
|
+
unsigned char t[256] = {
|
28
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
29
|
+
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
30
|
+
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
31
|
+
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
|
32
|
+
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
|
33
|
+
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
|
34
|
+
96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
|
35
|
+
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
|
36
|
+
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
|
37
|
+
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
|
38
|
+
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
|
39
|
+
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
|
40
|
+
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
|
41
|
+
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
|
42
|
+
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
|
43
|
+
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
|
44
|
+
};
|
45
|
+
|
46
|
+
int main(int argc, char *argv[])
|
47
|
+
{
|
48
|
+
if (argc != 3 || strlen(argv[1]) != strlen(argv[2])) {
|
49
|
+
fprintf(stderr, "usage: %s string1 string2\n", argv[0]);
|
50
|
+
return 1;
|
51
|
+
}
|
52
|
+
int c;
|
53
|
+
unsigned char b;
|
54
|
+
for (c = 0; (b = argv[1][c]) != '\0'; c++)
|
55
|
+
t[b] = argv[2][c];
|
56
|
+
while ((c = getchar()) != EOF)
|
57
|
+
putchar(t[c]);
|
58
|
+
}
|
20
59
|
```
|
1
誤字の修正
answer
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
あまり参考にならないかもしれませんが。
|
2
2
|
```C
|
3
3
|
#include <stdio.h> // getchar, putchar
|
4
|
-
#include <
|
4
|
+
#include <string.h> // strlen
|
5
5
|
|
6
6
|
#define T2(x) x,x+1,x+2,x+3
|
7
7
|
#define T1(x) T2(x),T2(x+4),T2(x+8),T2(x+12)
|