1.дано натуральное число. найти первую цифру данного числа. 2.дано натуральное число. определить количество троек в нем. 3.дано натуральное число. определить количество четных цифр в нем. все это при цикла: while
1. var a,b:integer; begin readln(a); while a>0 do begin b:=a mod 10; a:=a div 10; end; writeln ('Первая цифра: ',b); end.
2. var n, count :integer; begin readln(n); while n>0 do begin if n mod 10=3 then count :=count +1; n:=n div 10; end; write(count ); end.
3. var n,i,count :integer; begin readln(n); while n> 0 do begin i:=n mod 10; if odd(i)=false then count :=count +1; n:=n div 10; end; writeln('Кол-во четных цифр: ',count ); end.
// JavaScript var = function (array, minValue, maxValue){ var isInLimit = function (value) { return value >= minValue && value <= maxValue; } var = function (array, func) { var results = []; array.forEach(function(element, index, array) { if (!!func(element)) { results.push(index); } }); return results; } return (array, isInLimit); }
// That's an example of using the function ([1, 5, 2, 3, 4], 1, 3);
begin
readln(a);
while a>0 do
begin
b:=a mod 10;
a:=a div 10;
end;
writeln ('Первая цифра: ',b);
end.
2.
var n, count :integer;
begin
readln(n);
while n>0 do
begin
if n mod 10=3 then count :=count +1;
n:=n div 10;
end;
write(count );
end.
3.
var n,i,count :integer;
begin
readln(n);
while n> 0 do
begin
i:=n mod 10;
if odd(i)=false then count :=count +1;
n:=n div 10;
end;
writeln('Кол-во четных цифр: ',count );
end.