Created
May 12, 2016 19:54
-
-
Save pluralism/9c30b0a69577c7588e4c814995fde13b 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
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