Answer to Question #7947 in Delphi | Pascal for peter

Question #7947
please help.using sets: Let the text, ending with a point and consisting of the words divided by blanks. A word-sequence of latin letters. Print the words of the text having odd number in which there is no repeating letter.
1
Expert's answer
2012-03-30T09:31:43-0400
program Prog;
const
& alphU: array [1..26] of char =
('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
& alphL: array [1..26] of char =
('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
var
& s, ss, sf: String;
& i, j, k: integer;
& f: array[1..26]of boolean;
& fl:boolean;
begin
& writeln('Write your string:');
& readln(s);
& i:=1;
& sf:='';
& while i<=length(s) do
& begin
ss:='';
while (s[i]<>' ')and(s[i]<>'.') do
begin
ss:=ss+s[i];
inc(i);
end;
inc(i);
if (length(ss)mod 2)=1 then
begin
for j:=1 to 26 do f[j]:=true;
fl:=false;
for j:=1 to length(ss) do
begin
& for k:=1 to 26 do
& begin
if (ss[j]=alphU[k])or(ss[j]=alphL[k])then
& if f[k] then f[k]:=false
else
begin
& fl:=true;
& break;
end;
& end;
if fl then begin break; end;
end;
if not fl then sf:=sf+ss+' ';
end;
& end;
& if sf='' then writeln('.') else
& begin
sf[length(sf)]:='.';
writeln(sf);
& end;
end.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

peter
30.03.12, 19:22

wow! you are really good.thanks a lot but i would have really loved it if you wrote it using sets and not array.can you do that? please..

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS