Viết chương trình nhập vào 2 số nguyên m,n . Tính và đưa ra màn hình tổng các số chẵn
2 câu trả lời
Mình dùng theo kiểu file nè:
Program BTH;
var a,b,c:longint;
t:text;
Procedure init;
Begin
assign(t,'tinht.inp');reset(t);
readln(t,a,b);
close(t);
end;
procedure timize;
begin
c:=a+b;
end;
Procedure print;
begin
assign(t,'tinht.out');rewrite(t);
write(t,c);
close(t);
end;
begin
init;
timize;
print;
end.
var a,b,i,tong:integer;
begin
write('a=');readln(a);
write('b=');readln(b);
tong:=a+b;
writeln(' Tong la: ',tong);
if (tong mod 2=0) then writeln(' Tong la so chan ')
else write(' Tong la so le: ');
readln;
end.
Câu hỏi trong lớp
Xem thêm