Created
August 16, 2010 05:46
-
-
Save vicalejuri/526491 to your computer and use it in GitHub Desktop.
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> | |
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