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.
program du_lieu;
uses crt;
var i,n:integer;
a:array[1..100]of integer;
tbc:real;
f:text;
begin
clrscr;
assign(f,'DULIEU.INP');reset(f);
readln(f,n);
for i:=1 to n do
begin
read(f,a[i]);
end;
close(f);
for i:=1 to n do
tbc:=tbc+a[i];
writeln(tbc/n);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,j;
bool kt;
int main()
{
freopen("nguyento.inp","r",stdin);
freopen("nguyento.out","w",stdout);
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]>1)
{
kt=true;
for (j=2; j*j<=a[i]; j++)
if (a[i]%j==0) kt=false;
if (kt==true) cout<<a[i]<<" ";
}
return 0;
}
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.
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.
Program hotrotinhoc;
const fi='lientiep.inp';
fo='lientiep.out';
var f: text;
a,b: array[1..32000] of integer;
k,i,n,max,vtd,vtc: integer;
procedure ip;
begin
assign(f,fi);
reset(f);
readln(f,n,k);
for i:=1 to n do read(f,a[i]);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
max:=0; i:=1;
while i<=n do
begin
j:=i;
t:=a[i];
while (a[j]<a[j+1]) and (j<=n) do
begin
inc(j);
t:=t+a[j];
end;
if t>max then
begin
max:=t;
vtd:=i;
vtc:=j;
end;
i:=j+1;
end;
for i:=vtc downto vtd do
begin
inc(d1);
b[d1]:=a[i];
end;
for i:= k dowto 1 do
write(f,b[i],' ');
close(f);
end;
begin
ip;
out;
end.