Skip to content

Instantly share code, notes, and snippets.

@byelims
byelims / permutations
Created September 6, 2013 08:30
a simple way to generate permutations
#include <stdio.h>
void print_array(int array[], int n)
{
int i;
for (i = 0; i < n; i++) {
printf("%d%s", array[i], i != n-1 ? " " : "\n");
}
}
@byelims
byelims / convert integer to string
Created August 14, 2013 06:56
From USACO Section 1.2 Palindromic Squares
/* put the base b representation of n into s: 0 is represented by "" */
void
numbconv(char *s, int n, int b)
{
int len;
if (n == 0) {
strcpy(s, "");
return;