-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathd47_srack_ch.c
More file actions
47 lines (44 loc) · 789 Bytes
/
d47_srack_ch.c
File metadata and controls
47 lines (44 loc) · 789 Bytes
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
//getOddEvenString
#include<stdio.h>
#include<stdlib.h>
char* getOddEvenString(int N)
{
int exit;
int *arr = (int *)malloc(sizeof(int));
char *charr = (char *)malloc(sizeof(char));
int i=0,j=0,m=0;
long ctr=N;
while(ctr!=0)
{
ctr/=10;
i++;
}
while (j<i)
{
arr[j] = N%10;
printf("%d",arr[j]);
N/=10;
j++;
}
while(m<i)
{
for(int k=i-1;k>=0;k--)
{
if(arr[k]==0)
charr[m] = 'e';
else if (arr[k]%2==0)
charr[m] = 'e';
else if (arr[k]%2!=0 && arr[k]!=0)
charr[m] = 'o';
m++;
}
}
return charr;
}
int main(void)
{
int N;
scanf("%d",&N);
printf("String %s",getOddEvenString(N));
return 0;
}