-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day 6: Let's Review.c
48 lines (45 loc) · 1.13 KB
/
Day 6: Let's Review.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int counter,i,j=0,k=0,n;
char str[10000];
char *str1,*str2;
scanf("%d",&counter);
for(n=0 ; n<counter ; n++)
{
scanf("%s",str);
if (strlen(str)%2==0)
{
str1 = (char*)calloc(strlen(str),sizeof(char));
str2 = (char*)calloc(strlen(str),sizeof(char));
j=0,k=0;
for(i=0;i<strlen(str)/2;i++)
{
*(str1+j)=str[2*i];
*(str2+k)=str[(2*i) + 1];
j++;
k++;
}
}
else if (strlen(str)%2!=0)
{
str1 = (char*)calloc(strlen(str),sizeof(char));
str2 = (char*)calloc(strlen(str),sizeof(char));
j=0,k=0;
for(i=0;i<(strlen(str)+1)/2;i++)
{
*(str1+j)=str[2*i];
*(str2+k)=str[(2*i)+1];
j++;
k++;
}
}
printf("%s %s",str1,str2);
printf("\n");
free(str1);
free(str2);
}
return 0;
}