FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp/F20RecursionAssignment/PairStar.cpp at main · roydevashish/cpp · GitHub
roydevashish
/
cpp
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp
/
F20RecursionAssignment
/
PairStar.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
64 lines (48 loc) · 1014 Bytes
Breadcrumbs
cpp
/
F20RecursionAssignment
/
PairStar.cpp
Copy path
File metadata and controls
64 lines (48 loc) · 1014 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
Title: Pair Star
Problem statement
Given a string S, compute recursively a new string where identical chars that are adjacent in the
original string are separated from each other by a "*".
Detailed explanation ( Input/output format, Notes, Images )
Input format :
String S
Output format :
Modified string
Constraints :
0 <= |S| <= 1000
where |S| represents length of string S.
Sample Input 1 :
hello
Sample Output 1:
hel*lo
Sample Input 2 :
aaaa
Sample Output 2 :
a*a*a*a
*/
#
include
<
iostream
>
using
namespace
std
;
void
PairStar
(
char
input[]) {
if
(input[
0
] ==
'
\0
'
) {
return
;
}
PairStar
(&input[
1
]);
if
(input[
0
] == input[
1
]) {
int
count =
0
;
while
(input[count] !=
'
\0
'
) {
count++;
}
while
(count >
0
) {
input[count+
1
] = input[count];
count--;
}
input[
1
] =
'
*
'
;
}
return
;
}
int
main
() {
char
input[
100
];
cin.
getline
(input,
100
);
PairStar
(input);
cout << input << endl;
}
Back
|
FazBrowse Home
|
New Git URL