HOC24
Lớp học
Môn học
Chủ đề / Chương
Bài học
2
program bt2;
var i,n,t:integer;
begin
readln(n);
s:=0;
for i:=1 to n do
if i mod 2 = 1 then s:=s+i;
readln;
end.
3
program Cacsole;uses crt;var M, N, i: integer;beginclrscr;write ('Nhap M= '); readln(M);write ('Nhap N= '); readln(N);for i := M to N do
if i mod 2 = 1 thenwrite (i,' ');readln;end.
program Min;uses crt;var i,n:integer;begin clrscr; write('Nhap n: '); readln(n); write('Cac so le nho hon hoac bang ',n,'la :'); for i:=1 to n do if i mod 2 = 1 then write(i:4); readlnend.
uses crt;
var n,d,dem,i,x,y,t:integer;
st:string;
clrscr;
repeat
write('Nhap n='); readln(n);
until (1000<=n) and (n<=9999);
if n mod 2=0 then
str(n,st);
d:=length(st);
dem:=0;
for i:=1 to d do
val(st[i],x,y);
if x=0 then inc(em);
end;
writeln('So chu so 0 co trong so ',n,' la: ',dem);
end
else begin
t:=0;
t:=t+sqr(x);
writeln('Tong binh phuong cac chu so trong so ',n,' la: ',t);