Skip to content

Instantly share code, notes, and snippets.

@pluralism
Created May 12, 2016 19:54
Show Gist options
  • Save pluralism/9c30b0a69577c7588e4c814995fde13b to your computer and use it in GitHub Desktop.
Save pluralism/9c30b0a69577c7588e4c814995fde13b to your computer and use it in GitHub Desktop.
char convert(char *s, int numRows) {
int lenght = strlen(s);
char result = (char*)malloc(lenght * sizeof(char));
int resI = 0;
int line = 0;
int delimiter = 2;
int advancer = 0;
while(line < numRows){
int inChar = line;
while(inChar < lenght){
result[resI] = s[inChar];
resI++;
inChar += ((s * 2) - delimiter);
inChar += (((line + 1) * 2) - delimiter);
}
delimiter += 2;
line++;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment