@zundan Cat shuffle ????
Conversation
Notices
-
Eugen (gargron@mastodon.social)'s status on Friday, 28-Jan-2022 11:47:29 JST Eugen -
zunda (zundan@mastodon.zunda.ninja)'s status on Friday, 28-Jan-2022 11:47:51 JST zunda $ cat shuffle.c #include <stdlib.h>#include <stdio.h>#include <ctype.h>#include <time.h>
#define utf8_head(c) (((c) & 0xC0) != 0x80)
intmain(void){ char input[BUFSIZ], *runes[BUFSIZ]; char output[BUFSIZ]; size_t len, i, j; char *ptr;
fgets(input, sizeof(input), stdin); fclose(stdin);
ptr = input; while(*ptr) { if (utf8_head(*ptr) && *ptr != '\n') { runes[len] = ptr; len++; } ptr++; }
srand((unsigned)time(NULL)); for(i = 0; i < len - 1; i++) { j = i + rand() % (len - i); ptr = runes[j]; runes[j] = runes[i]; runes[i] = ptr; }
ptr = output; for(i = 0, ptr = output; i < len; i++) { j = 0; do { *ptr = *(runes[i] + j); j++; ptr++; } while(!utf8_head(*(runes[i] + j))); } *ptr = '\n'; *(ptr + 1) = '\0';
fputs(output, stdout); return EXIT_SUCCESS;}$ gcc -Wall shuffle.c && echo ねむいね | ./a.outいむねね
むっちゃ長くなったw
もちゃ(あと-4.00Kg) repeated this.
-