Câu 1 :
uses crt;
var a : array[1..100] of integer;
i,n,t : integer;
begin clrscr;
t:=0;
assign(input,'DULIEU.INP');
assign(output,'DULIEU.OUT');
reset(input); rewrite(output);
read(input,n);
for i:=1 to n do read(input,a[i]);
for i:=1 to n do if a[i] mod 5 <> 0 then t:=t+a[i];
write(output,t);
close(input); close(output);
readln
end.
Câu 2 :
uses crt;
var a : array[1..100] of integer;
i,n,t,j : integer;
begin clrscr;
t:=0; j:=0;
assign(input,'DULIEU.INP');
assign(output,'DULIEU.OUT');
reset(input); rewrite(output);
read(input,n);
for i:=1 to n do read(input,a[i]);
for i:=1 to n do if a[i] mod 2 <> 0 then begin
j:=j+1;
t:=t+a[i];
end;
write(output,t/j);
close(input); close(output);
readln
end.
Câu 3 :
uses crt;
var a : array[1..100] of integer;
i,n,t,j : integer;
begin clrscr;
t:=0; j:=0;
assign(input,'DULIEU.INP');
assign(output,'DULIEU.OUT');
reset(input); rewrite(output);
read(input,n);
for i:=1 to n do read(input,a[i]);
for i:=1 to n do if a[i] mod 2 = 0 then begin
j:=j+1;
t:=t+a[i];
end;
write(output,t/j);
close(input); close(output);
readln
end.
Bài 1.
uses crt;
var n,i,tong:longint; d:text; a:array[1..10000]of longint;
begin
clrscr;
write('n=');readln(n);
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
if a[i] mod 3=0 then inc(tong,a[i]);
end;
assign(d,'DULIEU.out');rewrite(d);
writeln(d,tong);
close(D);
end.
Bài 2.
uses crt;
var n,i,tong,t:longint; d:text; a:array[1..10000]of longint;
begin
clrscr;
write('n=');readln(n);
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
if a[i] mod 2=1 then begin inc(tong,a[i]); inc(t); end;
end;
assign(d,'DULIEU.out');rewrite(d);
writeln(d,tong/t:0:5);
close(D);
end.
Bài 3.
uses crt;
var n,i,tong,t:longint; d:text; a:array[1..10000]of longint;
begin
clrscr;
write('n=');readln(n);
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
if a[i] mod 2=0 then begin inc(tong,a[i]); inc(t); end;
end;
assign(d,'DULIEU.out');rewrite(d);
writeln(d,tong/t:0:5);
close(D);
end.
Mình làm các điều kiện vào chỗ nhập luôn để không cần làm thêm vòng for.
Có gì chưa hiểu hay là chương trình mắc phải lỗi sai hay có bạn nào tìm ra cách nào hay,ngắn hơn thì để lại bình luận nhé.
:))))
Tin học, tiếng Anh: informatics, tiếng Pháp: informatique, là một ngành khoa học chuyên nghiên cứu quá trình tự động hóa việc tổ chức, lưu trữ, xử lý và truyền dẫn thông tin của một hệ thống máy tính cụ thể hoặc trừu tượng (ảo). Với cách hiểu hiện nay, tin học bao hàm tất cả các nghiên cứu và kỹ thuật có liên quan đến việc mô phỏng, biến đổi và tái tạo thông tin.
Nguồn : Wikipedia - Bách khoa toàn thưLớp 12 - Năm cuối ở cấp tiểu học, năm học quan trọng nhất trong đời học sinh trải qua bao năm học tập, bao nhiêu kì vọng của người thân xung quanh ta. Những nỗi lo về thi đại học và định hướng tương lai thật là nặng. Hãy tin vào bản thân là mình sẽ làm được rồi tương lai mới chờ đợi các em!
Nguồn : ADMIN :))Copyright © 2021 HOCTAP247