Source code :
#include <iostream>
using namespace std;
int main(){
string s;
cout<<"Enter a string: ";
cin>>s;
for(int i=0;i<s.length();i++)
{
for(int j=s.length()-1;j>i;j--)
{
if(s[i]==s[j])
{
s.erase(j,1);
}
}
}
cout<<s;
return 0;
}
#include <iostream>
using namespace std;
int main(){
string s;
cout<<"Enter a string: ";
cin>>s;
for(int i=0;i<s.length();i++)
{
for(int j=s.length()-1;j>i;j--)
{
if(s[i]==s[j])
{
s.erase(j,1);
}
}
}
cout<<s;
return 0;
}
0 Comments
Post a Comment