herumi #4215(2007/11/19 04:01 GMT) [ C ] Rating0/0=0.00
つまりはこういうことでしょうか. 割り算を使わないという意図がいまいちくみ取れませんでした.すいません. #答えは2byte文字オンリーを仮定しています.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { int m = atoi(argv[1]); const char *s = "ゆめよりもはかなき世のなかをなげきわびつゝあかしくらすほどに四月十よひにもなりぬれば木のしたくらがりもてゆく"; int n = strlen(s) / 2; int lineLen = 0; int i, j; while (n >= m) { lineLen++; n -= m; } for (i = 0; i < m; i++) { for (j = 0; j < lineLen; j++) { putchar(*s++); putchar(*s++); } if (n > 0) { putchar(*s++); putchar(*s++); n--; } putchar('\n'); } return 0; };
Rating0/0=0.00-0+
[ reply ]
herumi
#4215()
[
C
]
Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]