//Removing duplicate character in given statement
#include < iomanip >
#include < iostream >
using namespace std;
void main()
{
char arr[20],newarr[20],sv;
short i=0,len,j,ns=1;
cout << "Enter your statement without space" << endl;
cin.getline(arr,20);
len=strlen(arr);
cout<< endl<< arr;
newarr[0]=arr[0];
while(++i < len)
{
newarr[ns]=sv=arr[i];
j=0;
while(sv!=newarr[j])
j++;
if(j==ns)
ns++;
}
newarr[ns]='\0';
cout << endl << "Statement after removing dups";
cout << endl << newarr << endl;
system("pause");
}
Subscribe to:
Post Comments (Atom)
Comments (0)
Post a Comment