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 n,i,s,t,j,max:longint;a,b:array[1..100] of longint;tbc:real;
function snt(n:longint):boolean;
var j:longint;
begin
for j:=2 to trunc(sqrt(n)) do
if n mod j=0 then exit(false);
exit(n>1);
end;
begin
readln(N);
for i:=1 to n do
begin
read (a[i]);
if snt(a[i])=true then
begin
j:=j+1;
b[j]:=a[i];
end;
end;
t:=b[1];
max:=b[1];
for i:=2 to j do
begin
if b[i]>max then max:=b[i];
t:=t+b[i];
write(b[i]:4);
end;
tbc:=t/j;
writeln(S);
writeln(tbc);
writeln(max);
readln;
end.
Câu 1:
uses crt;
var a:array[1..200]of integer;
i,n,t:integer;
begin
clrscr;
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
if a[i] mod 2=0 then t:=t+a[i];
writeln(t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> mp;
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
freopen("MAP1.INP","r",stdin);
freopen("MAP1.OUT","w",stdout);
ll n; cin >> n;
ll a[n+5];
for(ll i=1;i<=n;i++) cin >> a[i], mp[a[i]]++;
for(pair<ll,ll> it:mp) cout << it.first << " " << it.second << "\n";
}
Chúc bạn học tốt!
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âu 1:
uses crt;
var a:array[1..100]of real;
i,n:integer;
t:real;
begin
clrscr;
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
if a[i] mod 2=0 then t:=t+a[i];
writeln(t:4:2);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
t:real;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=1;
for i:=1 to n do
t:=t*a[i];
writeln(t:4:2);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t,ln,nn:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=0;
for i:=1 to n do
if a[i]>0 then t:=t+a[i];
ln:=a[1];
nn:=a[1];
for i:=1 to n do
begin
if ln<a[i] then ln:=a[i];
if nn>a[i] then nn:=a[i];
end;
writeln(t);
writeln(ln);
writeln(nn);
readln;
end.
program bt;
uses crt;
var i, s, sa, sd, sc, sl, da, dd, dc, dl : integer;
a : array[1..50] of integer;
begin
clrscr;
for i:=1 to 10 do begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
end;
write('Day so vua nhap la: ');
for i:=1 to 10 do write(a[i],', ');
writeln;
s := 0; sa := 0; sd := 0; sc := 0; sl := 0; da := 0; dd := 0; dc := 0; dl := 0;
for i:=1 to 10 do begin
s := s + a[i];
if (a[i] > 0) then begin sd := sd + a[i]; dd := dd + 1 end;
if (a[i] < 0) then begin sa := sa + a[i]; da := da + 1 end;
if (a[i] mod 2 = 0) then begin sc := sc + a[i]; dc := dc + 1; end
else begin sl := sl + a[i]; dl := dl + 1 end;
end;
writeln('Tong cac phan tu trong mang la ',s);
writeln('Trung binh cong cac phan tu trong mang la ',s/10);
writeln('Tong cac so am la ',sa);
writeln('Tong cac so duong la ',sd);
writeln('Tong cac so chan la ',sc);
writeln('Tong cac so le la ',sl);
writeln('So cac so am la ', da);
writeln('So cac so duong la ', dd);
writeln('So cac so chan la ', dc);
writeln('So cac so le la ', dl);
readln
end.
uses crt;
var i,n,x,dem,t,kt,j:integer;
a:array[1..100]of integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
dem:=0;
t:=0;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to trunc(sqrt(a[i])) do
if a[i] mod j=0 then
begin
kt:=1;
end;
if kt=0 then
begin
dem:=dem+1;
t:=t+a[i];
end;
end;
writeln(dem);
writeln(t);
readln;
end.