#include <iostream>
#include <string>
using namespace std;
void makeLevel(int n)
{
cout << "*" << endl;
string out ="**";
for(int level=1;level<=n;++level){
cout << out << endl;
out.push_back('*');
}
}
void tree(int n)
{
for(int i=1;i<=n;++i){
makeLevel(i);
}
}
{
cout << "*" << endl;
string out ="**";
for(int level=1;level<=n;++level){
cout << out << endl;
out.push_back('*');
}
}
void tree(int n)
{
for(int i=1;i<=n;++i){
makeLevel(i);
}
}
int main()
{
int n;
cin >> n;
tree(n);
return 0;
}
Объяснение:
1.
program z1;
const n=5;
var a:array [1..n,1..n] of integer;
i,j,s:integer;
begin
writeln ('Квадратная матрица:');
for i:= 1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=Random(10);
write(a[i,j]:3);
if i=j then s:=s+a[i,j]
end;
writeln;
end;
writeln('Среднее арифметическое элементов расположенных на главной диагонали: ',s/n)
end.
2.
program z2;
const n=5;
var a:array [1..n,1..n] of integer;
i,j,s,sp:integer;
begin
writeln ('Квадратная матрица:');
for i:= 1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=Random(21)-10;
write(a[i,j]:5);
if i=j then s:=s+a[i,j]
end;
writeln;
end;
for i:= 1 to n do
for j:=1 to n do
if (a[i,j]>0) and (a[i,j]>s/n)then sp:=sp+a[i,j];
writeln('Сумма положительных элементов, превышаюших по величине среднее арифметическое всех элементов расположенных на главной диагонали: ',sp)
end.
3.
program z3;
const n=5;
var a:array [1..n,1..n] of integer;
i,j,m,k:integer;
begin
writeln ('Двумерный массив:');
for i:= 1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=Random(21)-10;
write(a[i,j]:5)
end;
writeln;
end;
m:=a[1,1];
for i:= 1 to n do
for j:=1 to n do
if a[i,j]<m then m:=a[i,j];
writeln ('Минимальный элемент ',m);
k:=0;
for i:= 1 to n do
for j:=1 to n do
if a[i,j]=m then
begin
writeln('Индексы [',i,',',j,']');
k:=k+1;
end;
writeln ('Количество минимальных элементов ',k)
end.
i, n, j, b:integer;
c:array[1..200] of integer;
begin
readln(s);
readln(n);
a:=copy(s, 1, n);
for i:=1 to n do
val(a[i], c[i]);
for i:=1 to n do
for j:=1 to n do
if c[i]<c[j] then begin
b:=c[i]; c[i]:=c[j]; c[j]:=b; end;
for i:=1 to n do
str(c[i], d[i]);
s:=d;
writeln(s);
readln;
end.