Вот тебе простой вариант ришение задачи (коментар=пояснение)
PascalВыделить код
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 program prg; uses crt; var rez,chislo,min,max:integer; begin Write('Enter number = ');readln(chislo); //zanosim 1 chislo max:=chislo; //v max ta min min:=chislo; //chtobu potom mu soukb sravnivat s drugimi chislamu while (chislo<>0) do //zapuskaem zikl poka mu ne napishem 0 begin if (chislo>max)then max:=chislo; //sravnivaem s max if (chislo<min) then min:=chislo; //sravnivaem s min readln(chislo); //snova pihem chislo end; rez:=(max-min); //nahodim raznizy writeln('max(',max,') - min(',min,') = ',rez); //otvet end.
Const n=12; m=10; var a:array[1..n,1..m] of integer; i,j,k:integer; begin k:=0; for j:=1 to m do for i:=n downto 1 do begin k:=k+1; a[i,j]:=k; end; for i:=1 to n do begin for j:=1 to m do write(a[i,j]:4); writeln; end; end.
PascalВыделить код
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 program prg; uses crt; var rez,chislo,min,max:integer; begin Write('Enter number = ');readln(chislo); //zanosim 1 chislo max:=chislo; //v max ta min min:=chislo; //chtobu potom mu soukb sravnivat s drugimi chislamu while (chislo<>0) do //zapuskaem zikl poka mu ne napishem 0 begin if (chislo>max)then max:=chislo; //sravnivaem s max if (chislo<min) then min:=chislo; //sravnivaem s min readln(chislo); //snova pihem chislo end; rez:=(max-min); //nahodim raznizy writeln('max(',max,') - min(',min,') = ',rez); //otvet end.
var a:array[1..n,1..m] of integer;
i,j,k:integer;
begin
k:=0;
for j:=1 to m do
for i:=n downto 1 do
begin
k:=k+1;
a[i,j]:=k;
end;
for i:=1 to n do
begin
for j:=1 to m do write(a[i,j]:4);
writeln;
end;
end.
Результат:
12 24 36 48 60 72 84 96 108 120
11 23 35 47 59 71 83 95 107 119
10 22 34 46 58 70 82 94 106 118
9 21 33 45 57 69 81 93 105 117
8 20 32 44 56 68 80 92 104 116
7 19 31 43 55 67 79 91 103 115
6 18 30 42 54 66 78 90 102 114
5 17 29 41 53 65 77 89 101 113
4 16 28 40 52 64 76 88 100 112
3 15 27 39 51 63 75 87 99 111
2 14 26 38 50 62 74 86 98 110
1 13 25 37 49 61 73 85 97 109