Skip to content

Instantly share code, notes, and snippets.

@vicalejuri
Created August 16, 2010 05:46
Show Gist options
  • Save vicalejuri/526491 to your computer and use it in GitHub Desktop.
Save vicalejuri/526491 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
char* cycle(int start, int next, int repeatafter, int windowsize){
int j;
char *str = malloc( sizeof(char) * windowsize + 1);
for(j=0;j < windowsize; ++j)
str[j] = 0x30 + ((start + next*j) % (repeatafter+1));
str[j] = '\0';
return str;
}
int main(int argc, const char *argv[])
{
int i;
for(i=0; i < 10; ++i)
printf("%s\n" , cycle(i, 1, 5, 3));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment