Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main(void)
- {
- int i, j, k, half;
- char str[256], str2[256], finlaStr[256];
- scanf("%s", str);
- half = strlen(str)/2;
- if(strlen(str) % 2) half++;
- /* Split the string */
- for(i = 0, j = half; j < strlen(str);i++ ,j++)
- {
- str2[i] = str[j];
- }
- str2[i] = '\0';
- str[half] = '\0';
- /* constructing the final string based on the two halves */
- for(i = 0, k = 0; i < half; i++, k += 2)
- {
- finlaStr[k] = str[i];
- finlaStr[k+1] = str2[i];
- }
- finlaStr[k] = '\0';
- printf("%s\n", finlaStr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement