Program Loto<span>;
</span>Uses Crt<span>;
</span><span>Const lt = 49; <span>(* количество шаров в лототроне *)
</span></span><span>shar = 6; <span>(* количество выигрышных шаров*)
</span></span><span>Var lott,vyb : array [1..shar] of integer<span>;
</span></span><span>i, j, nom, k : integer<span>;
</span></span><span>m:set of byte<span>;
</span></span><span>Begin
</span><span>randomize<span>;
</span></span><span>m:=[]<span>;
</span></span><span>for i:=1 to shar <span>do
begin
repeat
</span></span><span>nom:=1+random(lt);
</span>until not(nom in m)<span>;
</span><span>lott[i]:=nom<span>;
</span></span><span>m:=m+[nom]<span>;
</span></span><span>end<span>;
</span></span><span>writeln('Выберите шаров от 1 до 6 ',lt)<span>;
</span></span><span>m:=[]<span>;
</span></span><span>begin
repeat
write('nom',i,'=');
readln(nom);
until (nom in [1..lt])and not(nom in m);
vyb[i]:=nom;
m:=m+[nom];
end;
clrscr<span>;
</span></span><span>writeln('Номера шаров в лототроне')<span>;
</span></span><span>for i:=1 to shar do
write(lott[i]:3);
writeln<span>;
</span></span><span>writeln('Выбранные шары');
for i:=1 to shar do
write(vyb[i]:3)<span>;
</span></span><span>writeln;
write('Совпавшие шары: ');
k:=0<span>;
</span></span><span>for i:=1 to shar do
for j:=1 to shar <span>do
</span></span><span>if lott[i]=vyb[j] then
<span>begin
</span></span><span>k:=k+1<span>;
</span></span><span>write(lott[i]:3)<span>;
</span></span><span>end<span>;
</span></span><span>if k=0 then write('- нет'<span>)
</span></span><span>else write(' Их количество=',k<span>)
</span></span><span>end<span>.</span></span>
Var
a:array [1..10] of integer;
i,sum,kol:integer;
begin
for i:=1 to 10 do a[i]:=random(10)+1;
for i:=1 to 10 do write(a[i],' ');
writeln;
for i:=1 to 10 do
if a[i] mod 2=0 then sum:=sum+a[i] else kol:=kol+1;
writeln(sum);
writeln(kol);
end.
На c++
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int k;
cin >> k;
if (k >= 0)
{
k *= k;
cout << k << endl;
}
else
{
cout << k << "<0" << endl;
}
_getch();
return 0;}