Chung-chieh Shan 單中杰 · @ccshan
348 followers · 1529 posts · Server woof.group

/* */
/* Touch */
<stdio.h>
<stdlib.h>
<errno.h>
int main() {
int x = 0;
char old[99], new[99];
srand(arc4random());
while (1) {
int y = x + rand() % 2 * 2 - 1;
snprintf(old, 99, "%d", x);
snprintf(new, 99, "%d", y);
if (-1 == rename(old, new) && ENOENT == errno)
x = y;
}
}

#uselessprogram #include

Last updated 2 years ago

Chung-chieh Shan 單中杰 · @ccshan
344 followers · 1496 posts · Server woof.group
Chung-chieh Shan 單中杰 · @ccshan
339 followers · 1473 posts · Server woof.group
Chung-chieh Shan 單中杰 · @ccshan
329 followers · 1387 posts · Server woof.group

/* */
/* Silencing */

<stdio.h>
<stdlib.h>

const char A[] = "A", B[] = "B", C[] = "C";

int main() {
char buf[1000];
srand(arc4random());
if (fgets(buf, sizeof(buf), stdin)) {
for (char *c = buf; *c; ++c) {
switch (*c) {
case 'A': *c = A[rand() % sizeof(A)]; break;
case 'B': *c = B[rand() % sizeof(B)]; break;
case 'C': *c = C[rand() % sizeof(C)]; break;
default : *c = ' ';
}
}
fputs(buf, stdout);
}
return 0;
}

#uselessprogram #include

Last updated 2 years ago