Uses crt;
const
n = 5;
m = 10; {кол-во столбцов}
l = 10; {максимальная длина одной строки/слова}
{letters = 'ABCDEFGHIJKLMNNNNNNNNNNNNOPQRSTUVWXXXXXXXXXXYZabcdefghijklmnopqrstuvwxyz';}
file_path = 'data.txt';
type
SmallString = string[l];
WordsMas = array[1..n, 1..m] of SmallString;
var
words: WordsMas;
i, j, k: integer;
function RandomWord(n: integer): SmallString;
var
i: integer;
s: SmallString;
letters: string;
begin
letters := 'ABCDEFGHIJKLMNNNNNNNNNNNNOPQRSTUVWXXXXXXXXXXYZabcdefghijklmnopqrstuvwxyz';
s := '';
for i := 1 to n do
s := s + letters[Random(length(letters) - 1) + 1];
RandomWord := s;
end;
function Replace(s, find_text, replace_text: SmallString): SmallString;
var
i: integer;
begin
repeat
i := pos(find_text, s);
if i <> 0 then begin
delete(s, i, length(find_text));
insert(replace_text, s, i);
end;
until i = 0;
Replace := s;
end;
function Invert(s: SmallString): SmallString;
var
i: integer;
t: SmallString;
begin
t := '';
for i := 1 to length(s) do
t := s[i] + t;
Invert := t;
end;
function SwapCase(s: SmallString): SmallString;
var
i: integer;
begin
for i := 1 to length(s) do
if s[i] = upcase(s[i]) then
s[i] := chr(ord(s[i]) + 32)
else s[i] := upcase(s[i]);
SwapCase := s;
end;
procedure PrintMas(mas: WordsMas; name: string);
var
i, j: integer;
f: text;
begin
writeln(name);
for i := 1 to n do
begin
write(i, ': ');
for j := 1 to m do
write(mas[i, j]:l, '; ');
writeln;
end;
Assign(f, file_path);
Append(f);
writeln(f, name);
for i := 1 to n do
begin
write(f, i, ': ');
for j := 1 to m do
write(f, mas[i, j]:l, '; ');
writeln(f);
end;
Close(f);
end;
begin
Randomize;
ClrScr;
for i := 1 to n do
for j := 1 to m do
words[i, j] := RandomWord(Random(l - 5) + 5);
{words[i, j] := 'GoodXXMMNN';}
PrintMas(words, 'Original');
for i := 1 to n do
for j := 1 to m do
case i of
1: words[i, j] := Replace(words[i, j], 'N', 'X');
2: words[i, j] := Replace(words[i, j], 'X', 'M');
3: words[i, j] := Invert(words[i, j]);
4: words[i, j] := SwapCase(words[i, j]);
end;
PrintMas(words, 'New One');
Readln;
end.
Проверялось. Работает на Турбо паскале