This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) { | |
const char *messages[] = { "%d\n", "Fizz\n", "Buzz\n", "Fizzbuzz\n" }; | |
for (int i = 1; i <= 100; i++) | |
printf(messages[!(i % 3) | (!(i % 5) << 1)], i); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copyright (C) 1997-2013 Sam Lantinga <[email protected]> | |
This software is provided 'as-is', without any express or implied | |
warranty. In no event will the authors be held liable for any damages | |
arising from the use of this software. | |
Permission is granted to anyone to use this software for any purpose, | |
including commercial applications, and to alter it and redistribute it | |
freely. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Fisher-Yates shuffle | |
Assume rand is already seeded */ | |
void shuffle(my_type_t *A, size_t n) | |
{ | |
int i, j; | |
my_type_t t; | |
for (i = n-1; i > 0; i--) { | |
j = rand() % (i+1) /* random int, 0 <= j <= i */ | |
t = A[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float getTime() | |
{ | |
static uint_least64_t start = 0; | |
struct timeval tv; | |
if (start == 0) { | |
gettimeofday(&tv,NULL); | |
start = 1000000 * tv.tv_sec + tv.tv_usec; | |
return 0.0f; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> // I/O Junk | |
#include <stdlib.h> // For rand() | |
#include <unistd.h> // For usleep() | |
#include <signal.h> // For Signal handler | |
#ifdef __linux__ | |
#include <termios.h> // To change term settings (no echo mode) | |
#elif _WIN32 | |
#include <conio.h> | |
#else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <memory.h> | |
#include <string.h> | |
#include <assert.h> | |
// node structure | |
typedef struct list_t { | |
char *value; | |
struct list_t *next; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main (void) | |
{ | |
int i; | |
char s[] = " 0123456789"; | |
for (i = 9; i >= 0; i--) | |
printf("%.10s\n", s + i); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(void) | |
{ | |
int frames = 0; | |
double fpstimer; | |
double ticktimer = 0.0; | |
double last; | |
last = dtime(); | |
while (1) { | |
double now = getTime(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
int main(void) | |
{ | |
const void * const t[] = { malloc(1), NULL, malloc(1), NULL, malloc(1)}; | |
const size_t size = sizeof t / sizeof *t; | |
const void ** it = (const void **) t; | |
const void * const * const end = (const void **) t + size; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#this is what i am trying in c right now, but i think some of you guys can solve this with a small shell script | |
#i got the following folder structure: | |
#reaction pics | |
#-laughing | |
#->12321.jpg | |
#->321312.jpg | |
#-wat |
NewerOlder