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.
Bài 1
Var a:array:[1..99] of integer;
i,n:integer;
s:longint;
Begin
Repeat
Write('n = ');readln(n);
Until (n > 0) and (n < 100);
For i:=1 to n do
Begin
Write('Nhap diem thu ',i,' = ');readln(a[i]);
if a[i] mod 2 = 0 then s:=s+a[i];
End;
Write('Cac so vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
write('Tong cac so chan la ',s);
Readln
End.
Bài 2
Var a:array:[1..99] of integer;
i,n:integer;
s:longint;
Begin
Repeat
Write('n = ');readln(n);
Until (n > 0) and (n < 100);
For i:=1 to n do
Begin
Write('Nhap diem thu ',i,' = ');readln(a[i]);
if a[i] mod 2 <> 0 then s:=s+a[i];
End;
Write('Cac so vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
write('Tong cac so le la ',s);
Readln
End.
Program HOC24;
var a: array[1..1000] of integer;
i,n,d: integer;
tbc: real;
t: longint;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do t:=t+a[i];
writeln('Tong cac phan tu cua mang la: ',t);
d:=0;
for i:=1 to n do if a[i]=5 then d:=d+1;
writeln('Co ',d,' phan tu co gia tri bang 5');
tbc:=0;
for i:=1 to n do if a[i] mod 2=1 then tbc:=tbc+a[i];
tbc:=tbc/n;
writeln('Trung binh cong cac phan tu le la: ',tbc:6:2);
write('Mang sau khi thay la: ');
for i:=1 to n do if a[i]=0 then a[i]:=10;
for i:=1 to n do write(a[i],' ');
readln
end.
Bài 1:
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.
Bài 2:
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.
c:
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]%2==0) cout<<a[i]<<" ";
return 0;
}
d:
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i,nn;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
nn=a[1];
for (i=1; i<=n; i++) nn=min(nn,a[i]);
cout<<nn;
return 0;
}
uses crt;
var a:array[1..1000]of integer;
i,n,t,j:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do
begin
t:=0;
for j:=1 to a[i] div 2 do
if a[i] mod j=0 then t:=t+j;
if t=a[i] then write(a[i]:4);
end;
readln;
end.
Var a:array[1..100] of integer;
i,n:integer;
s:longint;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
s:=s+a[i];
End;
Write('Cac phan tu vua nhap la ');
For i:=1 to n do
Write(a[i]:8);
Writeln;
Write('Tong cua chung la ',s);
Readln
End.
program SoNguyenTo;
var
A: array[1..100] of integer;
n, i, j: integer;
snt: boolean;
begin
write('Nhap so phan tu: ');
readln(n);
for i := 1 to n do
begin
write('Nhap phan tu A[', i, ']: ');
readln(A[i]);
end;
writeln('Cac so nguyen to trong day:');
for i := 1 to n do
begin
snt := true;
if A[i] < 2 then
snt := false
else
for j := 2 to round(sqrt(A[i])) do
if A[i] mod j = 0 then
begin
snt := false;
break;
end;
if snt = true then
writeln(A[i]);
end;
end.
program SoNguyenTo;
var
A: array[1..100] of Integer;
i, n: Integer;
isPrime: Boolean;
function IsNumberPrime(num: Integer): Boolean;
var
j: Integer;
begin
IsNumberPrime := True;
if num <= 1 then IsNumberPrime := False
else
for j := 2 to Round(Sqrt(num)) do
if num mod j = 0 then
IsNumberPrime := False;
end;
begin
write('Nhap so phan tu cua mang: ');
readln(n);
for i := 1 to n do
begin
write('Nhap phan tu thu ', i, ': ');
readln(A[i]);
end;
writeln('Cac so nguyen to trong mang la: ');
for i := 1 to n do
begin
isPrime := IsNumberPrime(A[i]);
if isPrime then
write(A[i], ' ');
end;
end.