0

hello i need help about getting the Unique characters from inputed String.. in Turbo Pascal...thanks in advance!

Sample Output:

Enter a String: Mississippi
Unique Characters: Misp

any clue or ideas...or simply the code...
:-)

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Wolfgan
0

What do you have so far ?

uses crt;

var
i,z,j,y:integer;
word : string;


begin
clrscr;

z:=0;

write('Enter a String: ');
readln(word);

z:=length(word);


for i := 1 to z do
begin

for j:=i+1 to z do
begin

if word = word[j] then
begin
delete(word,j,1);
word:=word;
z:=length(word);

end;
end;
end;

for y :=1 to z do
begin
write(word[y]);
end;

readln;
end.


i Enter: Mississippi
but it displays: Missp

hope you can help me...thank you..!

0
var
  i: integer;
  Source, Dest: string;
  Chars: array[32..127] of Char;
begin
  try
    Source := '';
    Dest := '';
    ReadLn(Source);
    for i := 1 to Length(Source) do
        if not (Chars[Ord(Source[i])] <> '') then
        begin
           Chars[Ord(Source[i])] := Source[i];
           Dest := Dest + Source[i];
        end;
    WriteLn(Dest);
end;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.