program SoalUas2;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
filestr: text;
x,z:string;
jumlaha: array [1..700] of integer;
poschar,p: integer;
zs,huruf: string;
hurchar:char;
awalspasi: boolean;
ask,m:integer;
begin
{ TODO -oUser -cConsole Main : Insert code here }
assign (filestr,'c:/data/input.txt');
reset (filestr);
while not eof(filestr) do
begin
readln (filestr, x);
writeln (x);
end;
close (filestr);
writeln;
awalspasi:= false;
p:= length (x);
poschar:= 1;
while poschar <= p do
begin
huruf:= copy (x, poschar, 1);
if huruf=' ' then zs:= ''
else
if huruf='/' then
if awalspasi = false then
begin
z:= zs;
awalspasi:= true;
end
else z:= z + ' '+ zs
else
zs:=zs +huruf;
poschar:=poschar+1;
end;
writeln (z);
assign (filestr,'c:/data/output.txt');
rewrite (filestr);
writeln(filestr, z);
close (filestr);
writeln;
p:= length (z);
for poschar:= 1 to p do
begin
hurchar:= z[poschar];
for m:= 32 to 126 do
begin
ask:= ord(hurchar);
if m=ask then jumlaha[ask]:= jumlaha[ask]+1;
end;
end;
for m:= 32 to 126 do
begin
if jumlaha[m]>0 then
writeln (chr(m),' ',jumlaha[m]);
end;
readln;
end.
{$APPTYPE CONSOLE}
uses
SysUtils;
var
filestr: text;
x,z:string;
jumlaha: array [1..700] of integer;
poschar,p: integer;
zs,huruf: string;
hurchar:char;
awalspasi: boolean;
ask,m:integer;
begin
{ TODO -oUser -cConsole Main : Insert code here }
assign (filestr,'c:/data/input.txt');
reset (filestr);
while not eof(filestr) do
begin
readln (filestr, x);
writeln (x);
end;
close (filestr);
writeln;
awalspasi:= false;
p:= length (x);
poschar:= 1;
while poschar <= p do
begin
huruf:= copy (x, poschar, 1);
if huruf=' ' then zs:= ''
else
if huruf='/' then
if awalspasi = false then
begin
z:= zs;
awalspasi:= true;
end
else z:= z + ' '+ zs
else
zs:=zs +huruf;
poschar:=poschar+1;
end;
writeln (z);
assign (filestr,'c:/data/output.txt');
rewrite (filestr);
writeln(filestr, z);
close (filestr);
writeln;
p:= length (z);
for poschar:= 1 to p do
begin
hurchar:= z[poschar];
for m:= 32 to 126 do
begin
ask:= ord(hurchar);
if m=ask then jumlaha[ask]:= jumlaha[ask]+1;
end;
end;
for m:= 32 to 126 do
begin
if jumlaha[m]>0 then
writeln (chr(m),' ',jumlaha[m]);
end;
readln;
end.
Tidak ada komentar:
Posting Komentar