Skip to content

Commit 215e5b0

Browse files
authored
Remove repeated digits in a given number.cpp
1 parent 0b72e9f commit 215e5b0

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
void removerrepeated(ll n)
3+
{
4+
stack<ll>s;
5+
s.push(-1);
6+
ll val;
7+
while(n)
8+
{
9+
val=n%10;
10+
11+
if(val!=s.top())
12+
{
13+
s.push(val);
14+
}
15+
n=n/10;
16+
}
17+
while(s.top()!=-1)
18+
{
19+
ll data=s.top();
20+
cout<<data;
21+
s.pop();
22+
}
23+
}
24+
int main()
25+
{
26+
//code
27+
ll t;
28+
cin>>t;
29+
while(t--)
30+
{
31+
ll n;
32+
cin>>n;
33+
removerrepeated(n);
34+
cout<<endl;
35+
}
36+
return 0;
37+
}

0 commit comments

Comments
 (0)