Skip to content

Instantly share code, notes, and snippets.

@ajaynitt
ajaynitt / 012sortArray.cpp
Created January 9, 2016 10:18
Sort an array of 0s, 1s and 2s
// C program to sort an array with 0,1 and 2
// in a single pass
#include<stdio.h>
/* Function to swap *a and *b */
void swap(int *a, int *b);
// Sort the input array, the array is assumed to
// have values in {0, 1, 2}
void sort012(int a[], int arr_size)
@ajaynitt
ajaynitt / stringPermutation.cpp
Created December 9, 2014 13:55
Write a C program to print all permutations of a given string
# include <stdio.h>
/* Function to swap values at two pointers */
void swap (char *x, char *y)
{
char temp;
temp = *x;
*x = *y;
*y = temp;
}