-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremoveX.cpp
More file actions
48 lines (41 loc) · 737 Bytes
/
Copy pathremoveX.cpp
File metadata and controls
48 lines (41 loc) · 737 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
47
48
#include <iostream>
using namespace std;
int length(char input[])
{
int len = 0;
for (int i = 0; input[i] != '\0'; i++)
{
len++;
}
return len;
}
void removeXhelper(char input[], int start)
{
if (input[start] == '\0')
{
return;
}
removeXhelper(input, start + 1);
if (input[start] == 'x')
{
int n = length(input);
int i;
for (i = start + 1; i < n; i++)
{
input[i - 1] = input[i];
}
input[i - 1] = '\0';
}
}
void removeX(char input[])
{
int len = length(input);
removeXhelper(input, 0);
}
int main()
{
char input[100];
cin.getline(input, 100);
removeX(input);
cout << input << endl;
}