Name: Anonymous 2020-09-09 19:33
Just post any fucking code, can be fibs or even hello world
any fucking code
Array.from (document.getElementsByClassName ("trip")).forEach (e => { e.parentNode.parentNode.children [1].innerHTML = "I am a child seeking attention."; })
#include <stdio.h>
#include <stdlib.h>
char* b36(int n) {
static char buf[99];
int len = 0;
char *dig = "0123456789abcdefghijklmnopqrstuvwxyz";
if(!n) { buf[len++] = dig[0]; buf[len] = 0; return buf; }
int sgn = (n < 0); n = abs(n);
while(n) { buf[len++] = dig[n % 36]; n /= 36; }
if(sgn) buf[len++] = '-';
buf[len] = 0;
for(int i = 0, j = len-1; i < j; i++,j--) {
int x = buf[i], y = buf[j];
buf[i] = y; buf[j] = x;
}
return buf;
}
int main(int argc, char *argv[]) {
if(argc <= 1) {
printf("usage: b36 <number> [<number>...]\n");
exit(0);
}
while(argc > 1) {
int n = atoi(argv[1]);
printf("%d -> %s\n", n, b36(n));
argc--; argv++;
}
return 0;
}
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
char* lltoa(int64_t inp,int base){
const char bases_str[]="0123456789abcdefghijklmnopqrstuvwxyz";
size_t i=127;static char buf[128]={0};
char sgn=(inp<0)?inp=-inp,'-':' ';
do{buf[i--]=bases_str[inp%base];inp/=base;}while(inp );
buf[i]=sgn;return &buf[i];}
int main(int argc,char**argv){
for(int i=1;i<argc;i++){printf("%s\n\n",lltoa(atoll(argv[i]),36));}
Edited on 10/09/2020 07:21.
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
int64_t atoi64(char *str) {
int64_t n = 0;
sscanf(str, "%" PRId64, &n);
return n;
}
char* to_base(int base, int64_t num) {
if(base < 2 || 36 < base) return "???";
// include some padding
static char buffer[8*64 + 4] = {0};
char *str = (buffer + sizeof(buffer) - 2);
// long long is at least 64-bit
int sign = (num < 0); num = llabs(num);
do
{
*str-- = (num % base)["0123456789abcdefghijklmnopqrstuvwxyz"];
num /= base;
}
while(num);
if(sign) *str = '-'; else str++;
return str;
}
int main(int argc, char *argv[]) {
if(argc-1 < 1) {
puts("usage: to-base <use-base> [<decimal-number>...]");
exit(1);
}
int base = atoi(argv[1]);
for(int i = 2; i < argc; i++) {
int64_t num = atoi64(argv[i]);
printf("%" PRId64 " = %d#%s\n", num, base, to_base(base, num));
}
return 0;
}
#define atype __auto_type
#define enumc(name,...) typedef union{}name;name __VA_ARGS__;
#define istype(x,type) (_Generic((x),type:1,default:0))
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc,char**argv){
enumc(Colors,Red,Blue,Yellow,Green);
Colors Purple=Red;
atype Black=Blue;
#define isblue(x) (&Blue==&x)
#define isgreen(x) (&Green==&x)
#define ispurple(x) (&Purple==&x)
printf("%d:%d,%d:%d \n%d:%d,%d:%d,",istype(Purple,Colors),istype(Black,int),isblue(Blue),isblue(Red),
isblue(Black),ispurple(Purple),isblue(Yellow),isgreen(Green));
}
#include <stdio.h>
int fib(int n)
{
return n < 2 ? n : fib(n - 2) + fib(n - 1);
}
int main()
{
for (int i = 1; i <= 10; ++i)
printf("%d\n", fib(i));
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define W 640
#define H 480
int screen[H][W];
void imgout(char *fn) {
FILE *f = fopen(fn, "w");
fprintf(f, "P2\n%d %d\n%d\n", W, H, 255);
for(int j = 0; j < H; j++) for(int i = 0; i < W; i++) fprintf(f, "%d\n", screen[j][i]);
fclose(f);
}
void p(double x, double y) {
int xx = (int)x, yy = (int)y;
if(xx < 0 || W <= xx || yy < 0 || H <= yy) return;
screen[yy][xx] = 255;
}
void line(double x, double y, double A, double r) {
int x1 = (int)x, x2 = (int)(x + r*cos(-A));
int y1 = (int)y, y2 = (int)(y + r*sin(-A));
int steps = 2 + abs(x2-x1) + abs(y2+y1); // overestimation...
for(int i = 0; i <= steps; i++) {
x = i*x2 + (steps-i)*x1; x /= steps;
y = i*y2 + (steps-i)*y1; y /= steps;
p(x, y);
}
}
void point(double x, double y, double A, double r, double *outx, double *outy) {
double xx = x + r*cos(-A);
double yy = y + r*sin(-A);
*outx = xx; *outy = yy;
}
double d2r(double degrees) { return (degrees * M_PI / 180.0); }
void segment(int depth, double x, double y, double A, double r) {
if(depth <= 0) { line(x, y, A, r); return; }
segment(depth-1, x, y, A, (r/3)); point(x, y, A, (r/3), &x, &y); A += d2r(+60);
segment(depth-1, x, y, A, (r/3)); point(x, y, A, (r/3), &x, &y); A += d2r(-120);
segment(depth-1, x, y, A, (r/3)); point(x, y, A, (r/3), &x, &y); A += d2r(+60);
segment(depth-1, x, y, A, (r/3));
}
int main() {
double K = 0.5 * (H - (double)W / 3.0 * sin(d2r(60)));
segment(7, 0, H-K, 0.0, W);
imgout("koch.ppm");
return 0;
}
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
printf("Hello, World!\n");
usleep(100000);
execvp(argv[0], argv);
}
// https://fabiensanglard.net/fizzlefade/index.php
// uses a LCG instead of LFSR
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
enum { W=80, H=24, N=(W*H) };
enum { A=37, B=39 }; // relatively prime A, B, N
int array[N];
#define pr(...) do { printf( __VA_ARGS__); fflush(stdout); } while(0)
void gotoxy(int col, int row) { pr("\e[%d;%dH", row+1, col+1); }
void clear() { pr("\e[H\e[J"); }
int main() {
int pos = rand() % N;
clear();
for(int i = 0; i < N; i++) {
int row = pos / W, col = pos % W;
usleep(10000);
gotoxy(col, row);
if(array[pos]++) pr("="); else pr("*");
pos = (A*pos + B) % N; // Linear Congruence Generator (LCG)
}
gotoxy(0, H);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char rot13(char ch) {
static char *alpha = "abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char *x = strchr(alpha, ch);
if(x) return x[13];
else return ch;
}
int main(int argc, char *argv[]) {
if(argc <= 1) {
printf("usage: rot13 <msg> [<msg>...]\n");
exit(1);
}
for(int i = 1; i < argc; i++) {
char *str = argv[i];
while(*str) putchar(rot13(*str++));
putchar('\n');
}
return 0;
}