Друзья
Друзья


Код Delphi

Код Delphi:

program Project37;
{$APPTYPE CONSOLE}

Uses
SysUtils;

VAR
fIn, fOut: Text;
S,S1,S2: String;
i,n:integer;
A:array[1..26] of string;
BEGIN
for i:=65 to 90 do begin
A[i-64]:=chr(i);
end;

ASSIGNFILE(fIn,'d:\Text.in');
ASSIGNFILE(fOut,'d:\Text.out');
RESET(fIn);

WHILE NOT EOF (fIn) DO BEGIN
READLN(fIn,S);
END;

For i:=1 to length(S) do begin
S1:=UpCase(S[i]);
for n:=1 to 26 do begin
if S1=' ' then begin S2:=S2+' '; break; end
else if S1=A[n] then begin S2:=S2+IntToStr(n)+','; break; end;
end;
end;

ReWrite(fOut);
Writeln(fOut,S2);

CloseFile(fOut);
CloseFile(fIn);

end.




Код Pascal:

uses crt;
VAR
fIn, fOut: Text;
S,S1,S2: String;
i,n:integer;
A:array[1..26] of string;
BEGIN
Cls;

for i:=65 to 90 do begin
A[i-64]:=chr(i);
end;

ASSIGN(fIn,'d:\Text.in');
ASSIGN(fOut,'d:\Text.out');
RESET(fIn);

WHILE NOT EOF (fIn) DO BEGIN
READLN(fIn,S);
END;

For i:=1 to length(S) do begin
S1:=UpperCase(copy(S,i,1));
for n:=1 to 26 do begin
if S1=' ' then begin S2:=S2+' '; break; end
else if S1=A[n] then begin S2:=S2+IntToStr(n)+','; break; end;
end;
end;

ReWrite(fOut);
Writeln(fOut,S2);

Close(fOut);
Close(fIn);
END.


 
Самое популярное
Яндекс.Метрика