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.
uses crt;
var a:array[1..100]of integer;
i,n,dem,dem1,dem2,t:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]>0;
end;
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i]>10 then inc(dem);
writeln('So phan tu lon hon 10 la: ',dem);
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem1)
else inc(dem2);
end;
writeln('So luong so chan la: ',dem1);
writeln('So luong so le la: ',dem2);
t:=0;
s:=1;
for i:=1 to n do
begin
if (i mod 2=0) and (a[i] mod 2<>1) then t:=t+a[i];
if (i mod 2=1) and (a[i] mod 2=0) then s:=s*a[i];
end;
writeln('Tong cac so o vi tri chan co gia tri le la: ',t);
writeln('Tich cac so o vi tri le co gia tri chan la: ',s:4:2);
writeln('Cac so le la: ');
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
writeln;
writeln('Cac so chan va lon hon 10 la: ');
for i:=1 to n do
if (a[i] mod 2=0) and (a[i]>10) then write(a[i]:4);
readln;
end.
uses crt;
var a:array[1..1000]of integer;
i,n,k,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
for i:=1 to n do
if a[i]=k then
begin
writeln(i);
break;
end;
dem:=0;
for i:=1 to n do
if a[i]=k then inc(dem);
if dem>0 then writeln('Co ',dem,' phan tu bang ',k)
else writeln('Khong co phan tu nao bang ',k);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,k,dem:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
readln(k);
dem:=0;
for i:=1 to n do
if a[i]>k then inc(dem);
write(dem);
readln;
end.
Bai 2:
uses crt;
var a:array[1..100]of integer;
i,n,t,nn:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
nn:=a[1];
for i:=1 to n do
if nn>a[i] then nn:=a[i];
write(nn);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,t,dem;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
t=0;
dem=0;
for (i=1; i<=n; i++)
if ((a[i]>0) and (i%2==1))
{
t+=a[i];
dem++;
}
cout<<fixed<<setprecision(2)<<(t*1.0)/(dem*1.0);
return 0;
}
Bài 1:
Program HOC24;
var i,n,d : byte;
t: integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' : '); readln(a[i]);
end;
for i:=1 to n do if (a[i] mod 3=0) and (a[i] mod 5=0) then
begin
d:=d+1;
t:=t+a[i];
end;
writeln('Co ',d,' phan tu la boi cua 3 va 5');
write('Tong la: ',t);
readln
end.
Bài 2:
Program HOC24;
var i,n,k : byte;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' : '); readln(a[i]);
end;
write('Nhap k: '); readln(k);
for i:=1 to n do if a[i]=k then d:=d+1;
writeln('Co ',d,' phan tu bang ',k);
Write('Cac chi so do la: ');
for i:=1 to n do if a[i]=k then write(i,' ');
readln
end.
uses crt;
var a:array[1..1000]of integer;
i,n,dem,t:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=1000);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until abs(a[i])<=1000;
end;
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i]=0 then inc(dem);
writeln('So phan tu bang 0 la: ',dem);
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln('Tong cac phan tu chan la: ',t);
readln;
end.
n = int(input("Nhập n: "))
a = [ ]
for i in range(n):
a.append(int(input(f"Nhập phần tử a[{i}]: ")))
k = int(input("Nhập k: "))
count_greater = 0
count_divisible_by_three = 0
for num in a:
if num > k:
count_greater += 1
if sum(int(digit) for digit in str(num)) % 3 == 0:
count_divisible_by_three += 1
print(f"Số lớn hơn {k}: {count_greater} số")
print(f"Số có tổng các chữ số chia hết cho 3: {count_divisible_by_three} số")
uses crt;
var a:array[1..100]of integer;
i,n,dem,k:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
dem:=0;
for i:=1 to n do
if a[i]=k then inc(dem);
writeln('Trong day co ',dem,' phan tu co gia tri bang ',k);
readln;
end.
vậy???