найти среднюю длину и заменить нею слова последней строки.
Добавлено: 22 янв 2011, 13:25
найти среднюю длину и заменить нею слова последней строки.
выходит ошибка скажите что я делаю не правильно
[syntax='pascal']program h7V4Z7;
Uses crt;
type str=array [1..40] of string;
const
m=12;
Letters=['A'..'Z']+['a'..'z'];
procedure VVod_klav(var x:str;var n:integer);
var i:integer;
begin
writeln ('koli4ectBo strok',n);
for i:=1 to n do
begin
writeln('vvedite s[',i,']');
readln(x);
end;
writeln ('text cformipovovan');
readkey;
end;
procedure VVod_avt(var X:str; var n:integer);
var i:integer;
begin
X[1]:='Hark how the bells';
X[2]:='sweet silver bells';
X[3]:='all seem to say';
X[4]:='throw cares away';
X[5]:='Christmas is here';
X[6]:='bringing good cheer';
X[7]:='to young and old';
X[8]:='meek and the bold';
X[9]:='Ding dong ding dong ';
X[10]:='that is their song ';
X[11]:='with joyful ring ';
X[12]:='all caroling';
N:=12;
writeln;
writeln('text cformiroBoBaH');
end;
procedure Vivod(var X:str; size:integer);
var i:integer;
begin
for i:=1 to size do
writeln (X)
end;
Var
s: str;
l: LongInt;
i,j,n: integer;
x,w: string;
f: text;
y:byte;
old_color:byte;
ch,regim:char;
result,VVod:boolean;
res:real;
Begin
Old_Color:=Textattr;vvod:=false;
Repeat
window(1,1,80,25);
textattr:=black shl 4+yellow;
clrscr;
gotoxy(5,1); write(' labopatopHa9 Pabota #7');
window(20,8,60,18);
textattr:=black shl 4+yellow;
clrscr;
gotoxy(11,4); write(' F1 - BBod ctpok');
gotoxy(11,5); write(' F2 - BuBod ctpok');
gotoxy(11,6); write(' F3 - obpabotka ctrok');
gotoxy(11,7); write(' F4 - o nporpamme ');
gotoxy(11,8); write(' Esc - Exit ');
textcolor(yellow); gotoxy(12,2);write(' Baw Bubop? ');
ch:=Readkey;
if ch=#0 then
Begin
ch:=Readkey;
window(5,2,75,24);
textattr:=black shl 4+yellow;
clrscr;
case ch of
#59:Begin
write ('regim BBoda (1-s klabuatypi/2-abtomatu4eckoe fopmupoBaHue)');
regim:=readkey;
case regim of
'1':begin
writeln;
writeln('VVedute kolu4ectBo ctpok,N= ');readln(n);
vvod_klav(s,n);
VVod:=true;
readkey;
end;
'2':begin
begin
clrscr;
VVod_avt(s,n);
VVod:=true;
readkey;
end;
if vvod then writeln ('ctpoku bbedehu' )
else writeln ('ctpoku He BBedeHu');
readkey;
End;
#60:Begin
if vvod then
vivod(s,n)
else writeln('text ne vveden');
readkey;
end;
#61:Begin
vivod(s,n);
writeln;
if VVod then writeln ('ctpoku bbedehu' )
else writeln ('ctpoku He BBedeHu');
readkey;
l:=0;
n:=0;
for i:=1 to m do
begin
w:='';
for j:=1 to Length(s) do
begin
if s[j] in Letters then w:=w+s[j];
if not (s[j] in Letters) or (i=Length(s)) then
if w<>'' then
begin
l:=l+Length(w);
Inc(n);
w:='';
end;
end;
end;
WriteLn('srednaia dlina ',l/n:0:3);
ReadLn;
begin
for i:=length(X) downto 1 do
if (x[12]='all' )or (x[12]='caroling')
then insert(l/n,x[12],12);
begin
write('rezyltat');
readkey;
end;
end;
end;
#62:Begin
writeln('Onepacuu c massiBamu ctpok');
writeln('Haxo}|{deHue cpedheu dluHHu ctpok');
writeln('zameHa dluHHou cloBa nocledhei ctpoku');
Readkey;
End;
end;
end;
until(ch=#27);
window(1,1,80,25);
textattr:=Old_Color;
clrscr;
END.[/syntax]
выходит ошибка скажите что я делаю не правильно
[syntax='pascal']program h7V4Z7;
Uses crt;
type str=array [1..40] of string;
const
m=12;
Letters=['A'..'Z']+['a'..'z'];
procedure VVod_klav(var x:str;var n:integer);
var i:integer;
begin
writeln ('koli4ectBo strok',n);
for i:=1 to n do
begin
writeln('vvedite s[',i,']');
readln(x);
end;
writeln ('text cformipovovan');
readkey;
end;
procedure VVod_avt(var X:str; var n:integer);
var i:integer;
begin
X[1]:='Hark how the bells';
X[2]:='sweet silver bells';
X[3]:='all seem to say';
X[4]:='throw cares away';
X[5]:='Christmas is here';
X[6]:='bringing good cheer';
X[7]:='to young and old';
X[8]:='meek and the bold';
X[9]:='Ding dong ding dong ';
X[10]:='that is their song ';
X[11]:='with joyful ring ';
X[12]:='all caroling';
N:=12;
writeln;
writeln('text cformiroBoBaH');
end;
procedure Vivod(var X:str; size:integer);
var i:integer;
begin
for i:=1 to size do
writeln (X)
end;
Var
s: str;
l: LongInt;
i,j,n: integer;
x,w: string;
f: text;
y:byte;
old_color:byte;
ch,regim:char;
result,VVod:boolean;
res:real;
Begin
Old_Color:=Textattr;vvod:=false;
Repeat
window(1,1,80,25);
textattr:=black shl 4+yellow;
clrscr;
gotoxy(5,1); write(' labopatopHa9 Pabota #7');
window(20,8,60,18);
textattr:=black shl 4+yellow;
clrscr;
gotoxy(11,4); write(' F1 - BBod ctpok');
gotoxy(11,5); write(' F2 - BuBod ctpok');
gotoxy(11,6); write(' F3 - obpabotka ctrok');
gotoxy(11,7); write(' F4 - o nporpamme ');
gotoxy(11,8); write(' Esc - Exit ');
textcolor(yellow); gotoxy(12,2);write(' Baw Bubop? ');
ch:=Readkey;
if ch=#0 then
Begin
ch:=Readkey;
window(5,2,75,24);
textattr:=black shl 4+yellow;
clrscr;
case ch of
#59:Begin
write ('regim BBoda (1-s klabuatypi/2-abtomatu4eckoe fopmupoBaHue)');
regim:=readkey;
case regim of
'1':begin
writeln;
writeln('VVedute kolu4ectBo ctpok,N= ');readln(n);
vvod_klav(s,n);
VVod:=true;
readkey;
end;
'2':begin
begin
clrscr;
VVod_avt(s,n);
VVod:=true;
readkey;
end;
if vvod then writeln ('ctpoku bbedehu' )
else writeln ('ctpoku He BBedeHu');
readkey;
End;
#60:Begin
if vvod then
vivod(s,n)
else writeln('text ne vveden');
readkey;
end;
#61:Begin
vivod(s,n);
writeln;
if VVod then writeln ('ctpoku bbedehu' )
else writeln ('ctpoku He BBedeHu');
readkey;
l:=0;
n:=0;
for i:=1 to m do
begin
w:='';
for j:=1 to Length(s) do
begin
if s[j] in Letters then w:=w+s[j];
if not (s[j] in Letters) or (i=Length(s)) then
if w<>'' then
begin
l:=l+Length(w);
Inc(n);
w:='';
end;
end;
end;
WriteLn('srednaia dlina ',l/n:0:3);
ReadLn;
begin
for i:=length(X) downto 1 do
if (x[12]='all' )or (x[12]='caroling')
then insert(l/n,x[12],12);
begin
write('rezyltat');
readkey;
end;
end;
end;
#62:Begin
writeln('Onepacuu c massiBamu ctpok');
writeln('Haxo}|{deHue cpedheu dluHHu ctpok');
writeln('zameHa dluHHou cloBa nocledhei ctpoku');
Readkey;
End;
end;
end;
until(ch=#27);
window(1,1,80,25);
textattr:=Old_Color;
clrscr;
END.[/syntax]