masterstvo2012
Ученик
- Регистрация
- 5 Июн 2014
- Сообщения
- 10
- Реакции
- 0
- Баллы
- 0
Построение блок схем
Постройте пожалуйста блок-схемы по данным кодам:
1.uses crt;
const nmax=20;
var a:array[1..nmax,1..nmax] of integer;
n,i,j,mx:integer;
begin
clrscr;
randomize;
repeat
write('Размер матрицы до ',nmax,' n=');
readln
;
until n in [1..nmax];
writeln('Исходная матрица:');
for i:=1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=random(50);
if (j>=n-i+1)and(j>=i) then
begin
if(i=1)and(j=n) then mx:=a[i,j]
else if a[i,j]>mx then mx:=a[i,j];
textcolor(12);
end
else textcolor(15);
write(a[i,j]:3);
end;
writeln;
end;
textcolor(15);
writeln('Максимальный элемент в выделенной области=',mx);
readln
end.
2.Var
T:Array[1..30] of Integer;
i:Integer;
Begin
Randomize;
for i:=1 to 10 do T:=-12+Random(11);
for i:=11 to 20 do T:=-5+Random(11);
for i:=21 to 30 do T:=Random(11);
for i:=1 to 30 do write(T:4);
writeln;
writeln;
i:=0;
Repeat
i:=i+1;
Until T>0;
Writeln('n = ',i);
Readln
End.
3.Const
C=['a'..'z']+['A'..'Z']+['а'..'я']+['А'..'Я']+['0'..'9'];
Var
S:String;
L,L_min,i:byte;
Begin
Writeln('Enter the string:');
Readln(S);
L_min:=255;
i:=0;
Repeat
while not (S in C) do i:=i+1;
L:=0;
repeat
L:=L+1;
i:=i+1;
until not (S in C) or (i=Length(S));
if L<L_min then L_min:=L;
Until i=Length(S);
Writeln('Shortest word length is ',L_min);
Readln
End.
4.Const
C=['б','в','г','д','ж','з','к','л','м','н','п','р','с','т','ф','х','ц','ч','ш','щ']+
['Б','В','Г','Д','Ж','З','К','Л','М','Н','П','Р','С','Т','Ф','Х','Ц','Ч','Ш','Щ'];
Var
S:String;
W:Set of Char;
i:byte;
L:Char;
Begin
W:=[];
Writeln('Enter the string:');
Readln(S);
writeln;
for i:=1 to Length(S) do
if S in C then W:=W+[S];
for L:='б' to 'щ' do
if L in W then write(L+' ');
for L:='Б' to 'Щ' do
if L in W then write(L+' ');
Readln
End.
5.var c: char;
begin
write(' Введите символ: '); readln(c);
writeln(' Символьный код: ', byte(c));
writeln(' Предыдущий символ: ', pred(c));
writeln(Следующий символ ', succ(c));
readln
6.
var x, y: real;
begin
write('x = '); readln(x);
write('y = '); readln
;
writeln((y >= 2) and (x * x + y * y >= 16) and (x * x + y * y <= 36));
readln
end.
7. const m = 20;
var i, max: integer;
y: array [1..m] of integer;
begin
randomize;
max := -12;
writeln('Исходный массив');
for i := 1 to m do
begin
y := random(21) - 10;
write(y:4);
if not(odd(y)) and (y > max) then max := y
end;
writeln;
writeln(‘Максимум = ', max);
readln
end.
8.var h: string;
d: longint;
i, z: integer;
f: boolean;
begin
write(' шестнадцатеричное число= ');
readln(h);
if (length(h) = 0) or ((length(h) = 1) and (h[1] = '-'))
then writeln(‘Число не было введено')
else begin
if h[1] <> '-'
then z := 1
else begin
z := -1;
delete(h, 1, 1)
end;
if (length(h) > 8) or ((length(h) = 8) and (h[1] > 'E'))
then writeln('Количество слишком большое')
else begin
for i := 1 to length(h) do
begin
if h in ['a'..'f'] then h := char(byte(h) - byte('a') + byte('A'));
f := not(h in ['0'..'9', 'A'..'F']);
if f then break
end;
if f
then writeln('Это не шестнадцатеричное число')
else begin
d := 0;
for i := 1 to length(h) do
if h in ['0'..'9']
then d := d * 16 - byte('0') + byte(h)
else d := d * 16 - byte('A') + byte(h) + 10;
writeln(Десятичное число = ', z * d)
end;
end
end;
readln
end.
9. uses graph;
var x,y,n,gd,gm,i,c: integer;
begin
write('звезд=');
readln(N);
gd:=detect; {инициализация графики}
initgraph(gd,gm,'');
randomize;
for i:=1 to n do
begin
x:=random(640);
y:=random(480);
c:=random(16);
setcolor(c);
circle(x,y,1)
end;
readln
end.
Постройте пожалуйста блок-схемы по данным кодам:
1.uses crt;
const nmax=20;
var a:array[1..nmax,1..nmax] of integer;
n,i,j,mx:integer;
begin
clrscr;
randomize;
repeat
write('Размер матрицы до ',nmax,' n=');
readln
until n in [1..nmax];
writeln('Исходная матрица:');
for i:=1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=random(50);
if (j>=n-i+1)and(j>=i) then
begin
if(i=1)and(j=n) then mx:=a[i,j]
else if a[i,j]>mx then mx:=a[i,j];
textcolor(12);
end
else textcolor(15);
write(a[i,j]:3);
end;
writeln;
end;
textcolor(15);
writeln('Максимальный элемент в выделенной области=',mx);
readln
end.
2.Var
T:Array[1..30] of Integer;
i:Integer;
Begin
Randomize;
for i:=1 to 10 do T:=-12+Random(11);
for i:=11 to 20 do T:=-5+Random(11);
for i:=21 to 30 do T:=Random(11);
for i:=1 to 30 do write(T:4);
writeln;
writeln;
i:=0;
Repeat
i:=i+1;
Until T>0;
Writeln('n = ',i);
Readln
End.
3.Const
C=['a'..'z']+['A'..'Z']+['а'..'я']+['А'..'Я']+['0'..'9'];
Var
S:String;
L,L_min,i:byte;
Begin
Writeln('Enter the string:');
Readln(S);
L_min:=255;
i:=0;
Repeat
while not (S in C) do i:=i+1;
L:=0;
repeat
L:=L+1;
i:=i+1;
until not (S in C) or (i=Length(S));
if L<L_min then L_min:=L;
Until i=Length(S);
Writeln('Shortest word length is ',L_min);
Readln
End.
4.Const
C=['б','в','г','д','ж','з','к','л','м','н','п','р','с','т','ф','х','ц','ч','ш','щ']+
['Б','В','Г','Д','Ж','З','К','Л','М','Н','П','Р','С','Т','Ф','Х','Ц','Ч','Ш','Щ'];
Var
S:String;
W:Set of Char;
i:byte;
L:Char;
Begin
W:=[];
Writeln('Enter the string:');
Readln(S);
writeln;
for i:=1 to Length(S) do
if S in C then W:=W+[S];
for L:='б' to 'щ' do
if L in W then write(L+' ');
for L:='Б' to 'Щ' do
if L in W then write(L+' ');
Readln
End.
5.var c: char;
begin
write(' Введите символ: '); readln(c);
writeln(' Символьный код: ', byte(c));
writeln(' Предыдущий символ: ', pred(c));
writeln(Следующий символ ', succ(c));
readln
6.
var x, y: real;
begin
write('x = '); readln(x);
write('y = '); readln
writeln((y >= 2) and (x * x + y * y >= 16) and (x * x + y * y <= 36));
readln
end.
7. const m = 20;
var i, max: integer;
y: array [1..m] of integer;
begin
randomize;
max := -12;
writeln('Исходный массив');
for i := 1 to m do
begin
y := random(21) - 10;
write(y:4);
if not(odd(y)) and (y > max) then max := y
end;
writeln;
writeln(‘Максимум = ', max);
readln
end.
8.var h: string;
d: longint;
i, z: integer;
f: boolean;
begin
write(' шестнадцатеричное число= ');
readln(h);
if (length(h) = 0) or ((length(h) = 1) and (h[1] = '-'))
then writeln(‘Число не было введено')
else begin
if h[1] <> '-'
then z := 1
else begin
z := -1;
delete(h, 1, 1)
end;
if (length(h) > 8) or ((length(h) = 8) and (h[1] > 'E'))
then writeln('Количество слишком большое')
else begin
for i := 1 to length(h) do
begin
if h in ['a'..'f'] then h := char(byte(h) - byte('a') + byte('A'));
f := not(h in ['0'..'9', 'A'..'F']);
if f then break
end;
if f
then writeln('Это не шестнадцатеричное число')
else begin
d := 0;
for i := 1 to length(h) do
if h in ['0'..'9']
then d := d * 16 - byte('0') + byte(h)
else d := d * 16 - byte('A') + byte(h) + 10;
writeln(Десятичное число = ', z * d)
end;
end
end;
readln
end.
9. uses graph;
var x,y,n,gd,gm,i,c: integer;
begin
write('звезд=');
readln(N);
gd:=detect; {инициализация графики}
initgraph(gd,gm,'');
randomize;
for i:=1 to n do
begin
x:=random(640);
y:=random(480);
c:=random(16);
setcolor(c);
circle(x,y,1)
end;
readln
end.