Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
tham khảo
program tinhoc;
uses crt;
var n,dem,tich:integer;
a: array[1..1000] of integer;
begin
clrscr;
writeln('Nhap so phan tu cua day: ');readln(n);
writeln('Nhap ',n,' phan tu cua day: ');
for i:= 1 to n do readln(a[i]);
dem:=0; tich:=1;
for i:= 1 to n do if a[i] mod 2 = 0 then begin dem:=dem+1; tich:=tich*a[i] end;
writeln('Co ',dem,' phan tu chan trong day');
writeln('Tich cua cac so chan trong day la: ',tich);
readln
end.
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,dem;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x>0) dem++;
}
cout<<dem;
return 0;
}
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,tb:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
tb:=0;
for i:=1 to n do
tb:=tb+a[i];
writeln(tb/n:4:2);
readln;
end.
program mang;
uses crt;
var
N, i: integer;
a: array[1..100] of integer;
sum, average: double;
begin
clrscr;
write('Nhap so phan tu mang: ');
readln(N);
sum := 0;
for i:= 1 to N do
begin
write('Nhap phan tu thu ', i, ': ');
readln(a[i]);
sum := sum + a[i];
end;
writeln('Cac phan tu cua mang la:');
for i:= 1 to N do
write(a[i], ' ');
average := sum / N;
writeln('Tong cac phan tu cua mang la: ', sum:0:2);
writeln('Trung binh cong cua mang la: ', average:0:2);
readln;
end.
program trungbinh;
uses crt;
var n,i: integer;
s:real;
A: array[1..1000] of integer;
begin
clrscr;
write('Nhap do dai day: '); readln(n);
writeln('Nhap gia tri cua day: ');
S:=0;
for i:=1 to n do
begin
write('A[',i,']= ');
readln(A[i]);
S:=S+A[i];
end;
S:=S/n;
write('Trung binh cua cac so cua day do la: ',S);
readln;
end.
a) var a:array[1..1000] of integer;
i,k:integer;
p:longint;
begin
write('k = ');readln(k);
p:=1;
for i:=1 to k do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
if a[i]<30 then p:=p*a[i];
end;
write('Tich la ',p);
readln
end.
b)
var a:array[1..1000] of integer;
i,k:integer;
s:longint;
begin
write('k = ');readln(k);
for i:=1 to k do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
if a[i]<100 then s:=s+a[i];
end;
write('Tong la ',s);
readln
end.
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
readln;
end.
uses crt;
var a:array[1..1000000] of longint;
n,i:longint;
begin
clrscr;
write('Nhap so luong phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
end;
write('Cac so chan: ');
for i:=1 to n do if a[i] mod 2=0 then write(a[i],' ');
readln;
end.
program TinhTBC;
uses crt;
var
N, i: integer;
Tong, TBC : real;
A: array[1..100] of real;
begin
write('Nhap so phan tu mang N = ');
readln(N);
writeln('Nhap cac phan tu cua mang: ');
for i:=1 to N do
begin
write('A[', i, '] = ');
readln(A[i]);
end;
Tong := 0;
for i:=1 to N do
Tong := Tong + A[i];
TBC := Tong / N;
writeln('Tong cac phan tu: ', Tong:5:2);
writeln('Trung binh cong: ', TBC:5:2);
readln;
end.
Var a:array[1..1000] of integer;
s:longint;
i,n:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i);readln(a[i]);
If a[i] > 0 then s:=s+a[i];
End;
Write('Tong la ',s);
Readln
End.
Progam trung_binh_cong
uses crt;
var a,b,c:real;
begin
clrscr
write(nhap so a,b,c=’,)readln(a,b,c)
writeln(‘trung binh cong cua ba so=’,(a+b+c)/3;
readln;
end
phuongthao:
Progam trung_binh_cong
uses crt;
var a,b,c:real;
begin
clrscr
write(nhap so a,b,c=’,)readln(a,b,c)
writeln(‘trung binh cong cua ba so=’,(a+b+c)/3;
readln;
end
phuongthao:
Progam trung_binh_cong
uses crt;
var a,b,c:real;
begin
clrscr
write(nhap so a,b,c=’,)readln(a,b,c)
writeln(‘trung binh cong cua ba so=’,(a+b+c)/3;
readln;
end
ui cj viết TA