* Đối với kiểu in ra tổng âm, dương và các số của chúng:
Uses Crt;
Var a:array[1..1000] of real;
i,n:integer; ta,td:real;
Begin
Write('Nhap N= '); Readln(n);
For i:= 1 to n do
Begin
Write('Nhap a[',i,']= '); Readln(a[i]);
End;
ta:= 0; td:=0;
For i:=1 to n do
Begin
If a[i] > 0 then td:=td+a[i];
If a[i] < 0 then ta:=ta+a[i];
End;
Write(' Tong duong cua day so tren la: ',td:1:1);
Writeln;
Write(' Cac so duong cua day tren la: ');
For i:= 1 to n do If a[i] >0 then write(a[i]:6:1);
Writeln;
Write(' Tong am cua day so tren la: ',ta:1:1);
Writeln;
Write(' Cac so am cua day tren la: ');
For i:= 1 to n do if a[i] < 0 then write(a[i]:6:1);
Readln
End.
* Đối với kiểu in ra tổng chẵn, lẻ và in ra các số của chúng:
Var a:array[1..1000] of integer;
i,n,tc,tl:integer;
Begin
Write('Nhap N= '); Readln(n);
For i:= 1 to n do
Begin
Write('Nhap a[',i,']= '); Readln(a[i]);
End;
tc:=0; tl:=0;
For i:=1 to n do
Begin
If a[i] mod 2 = 0 then tc:=tc+a[i];
If a[i] mod 2 = 1 then tl:=tl+a[i];
End;
Write(' Tong chan cua day so tren la: ',tc:1);
Writeln;
Write(' Cac so chan cua day tren la: ');
For i:= 1 to n do If a[i] mod 2= 0 then write(a[i]:6);
Writeln;
Write(' Tong le cua day so tren la: ',tl:1);
Writeln;
Write(' Cac so le cua day tren la: ');
For i:= 1 to n do if a[i] mod 2 <>0 then write(a[i]:6);
Readln
End.
Tính tổng các phần tử dương:
uses crt;
var i,j,n,s:longint; a:array[1..1000000]of longint;
begin
clrscr;
write('Nhap n: ');readln(n);
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
if a[i]>0 then inc(s,a[i]);
end;
writeln('Tong cac so duong: ',s);
readln
end.
Tính tổng các phần tử âm:
uses crt;
var i,j,n,s:longint; a:array[1..1000000]of longint;
begin
clrscr;
write('Nhap n: ');readln(n);
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
if a[i]<0 then inc(s,a[i]);
end;
writeln('Tong cac so am: ',s);
readln
end.
Tính tổng các phần tử chẵn:
uses crt;
var i,j,n,s:longint; a:array[1..1000000]of longint;
begin
clrscr;
write('Nhap n: ');readln(n);
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
if a[i] mod 2=0 then inc(s,a[i]);
end;
writeln('Tong cac so chan: ',s);
readln
end.
Tính tổng các phần tử lẽ:
uses crt;
var i,j,n,s:longint; a:array[1..1000000]of longint;
begin
clrscr;
write('Nhap n: ');readln(n);
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
if a[i] mod 2=1 then inc(s,a[i]);
end;
writeln('Tong cac so le: ',s);
readln
end.
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 8 - Năm thứ ba ở cấp trung học cơ sở, học tập bắt đầu nặng dần, sang năm lại là năm cuối cấp áp lực lớn dần nhưng các em vẫn phải chú ý sức khỏe nhé!
Nguồn : ADMIN :))Xem thêm tại https://loigiaisgk.com/cau-hoi or https://giaibtsgk.com/cau-hoi
Copyright © 2021 HOCTAPSGK