Sử dụng ngôn ngữ lập trình Pascal để viết chương trình giải quyết các bài toán sau: Bài 1: Nhập vào một dãy các số nguyên, quá trình nhập dừng lại khi số nhập vào bằng 0. Tính tổng các số lớn hơn 0 trong dãy số vừa nhập Bài 2: Tìm ước số chung lớn nhất và bội số chung nhỏ nhất của 3 số nguyên a, b, c được nhập vào từ bàn phím. Giúp mình với,mình cần gấp lắm huhu!!!

2 câu trả lời

Bài 1 :

uses crt;

var n, s : integer;

begin

clrscr;

s := 0; n := -1;

while n <> 0 do

begin write('Nhap n : ');

readln(n); s := s + n; end;

write('S = ', s);

readln

end.

Bài 2 :

uses crt;

var i, min, a, b, c, uc : integer;

begin

clrscr;

write('Nhap ba so a, b, c : '); readln(a, b, c);

min := a;

if b <min then min := b;

if c < min then min := c;

for i := min downto 1 do

if (a mod min = 0) and (b mod min = 0) and (c mod min = 0)

then begin uc := i; break end;

i := min; while not ((i mod a = 0) and (i mod b = 0) and (i mod c = 0)) do

i := i + 1;

writeln('UCLN : ', uc);

writeln('BCNN : ', i);

readln

end.

Program BTH;
uses crt;
var s,i,n:longint;
Begin
        clrscr;
        i:=0;
        repeat
        i:=i+1;
        write('Nhap so thu ',i,' : ');readln(n);
        If n>0 then s:=s+n;
        until n=0;
        writeln('Tong cac so lon hon 0 trong day la: ',s);
        readln;
end.

Câu hỏi trong lớp Xem thêm

II. Choose the word or phrase that best completes each unfinished sentence below. 6. Radioactive pollution is increasing the increased use of radioactivity. A. as B. since C. because of D. because 7. Do you think there would be less conflict in the world if all people the same language? A. spoke B. speak C. had spoken D. will speak 8. Unless you all of my questions, I can’t do anything to help you. A. answered B. answer C. would answer D. are answering 9. Singapore is famous for its …………. streets and green trees. A. cleanliness B. cleanly C. cleaning D. clean 10. If someone into the store, smile and say, “May I help you?” A. comes B. came C. come D. should come 11. It was said that the fish died a powerful toxin in the sea water. A. because of B. because C. since D. as a result 12. “Here’s my phone number”. “Thanks. I’ll give you a call if I some help tomorrow” A. will need B. need C. would need D. needed 13. is the festival celebrated? – Every year. A. When B. How often C. How D. What 14. The death rate would decrease if hygienic conditions improved. A. was B. is C. were D. had been 15. On Christmas Eve, most big cities, especially London are _______ with coloured lights across the streets and enormous Christmas trees. A. decorated B. hang C. put D. made 16. If she him, she would be very happy. A. would meet B. will meet C. met D. should meet 17. Nga is a beautiful girl; ______ , she’s kind - hearted. A. therefore B. however C. moreover D. otherwise 18. If I had enough money, I abroad to improve my English. A. will go B. would go C. went D. should have go to 19. She has read interesting book. A. a B. an C. the D. Ø 20. If it convenient, let’s go out for a drink tonight. A. be B. is C. was D. were

7 lượt xem
1 đáp án
2 giờ trước