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.
var A:
array[1..n] of int64;
i, n, count: integer;
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;
count := 0;
for i := 1 to n do
if A[i] > 0 then
count := count + 1;
writeln('So luong cac so nguyen duong trong mang la: ', count); end.
Ngôn ngữ: C++
#include <bits/stdc++.h>
using namespace std;
long long n;
long long minx=LLONG_MAX;
long long a[100000];
int main()
{
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
sort(a+1,a+n+1);
for(int i=2;i<=n;i++){
minx=min(minx,a[i]-a[i-1]);
}
cout<<minx;
return 0;
}
uses crt;
var d,n,k,kt1,i,j,x,kt2,u,kt:longint;
st1,st2,st:string;
y:integer;
begin
clrscr;
write('nhap so k='); readln(k);
if k>1 then begin
d:=1;
n:=3;
repeat
repeat
kt:=0;
n:=n+2;
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then kt:=1;
if kt=0 then str(n,st1);
until kt=0;
{----------------------------------------}
repeat
kt:=0;
n:=n+2;
for j:=2 to trunc(sqrt(n)) do
if n mod j=0 then kt:=1;
if kt=0 then str(n,st2);
until kt=0;
{----------------------------------------}
kt:=0;
st:=st1+st2;
val(st,x,y);
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then kt:=1;
if kt=0 then d:=d+1;
until d=k;
end;
if k=1 then write('so nguyen to ghep thu ',k,' la 23')
else writeln('so nguyen to ghep thu ',k,' la: ',x);
readln;
end.
const fi='calc.inp';
fo='calc.out';
var f1,f2:text;
max,a,b,c,d1,t1,i,x,y,d2,t2,d,e,d3,t3,f,g:integer;
st1,st2,st3:string;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,a,b,c);
str(a,st1);
str(b,st2);
str(c,st3);
d1:=length(st1);
t1:=1;
for i:=1 to d1 do
begin
val(st1[i],x,y);
t1:=t1*x;
end;
d2:=length(st2);
t2:=1;
for i:=1 to d2 do
begin
val(st2[i],d,e);
t2:=t2*d;
end;
d3:=length(st3);
t3:=1;
for i:=1 to d3 do
begin
val(st3[i],f,g);
t3:=t3*f;
end;
max:=t1;
if max<t2 then max:=t2;
if max<t3 then max:=t3;
writeln(f2,max);
close(f1);
close(f2);
end.
uses crt;
var n,i,o,d:integer;
function ktnt(n:integer): integer;
var i,d:integer;
begin
d:=0;
for i:=1 to sqrt(n) do
if (n mod i=0) then d:=d+1;
if d=2 then ktnt=0
else ktnt=1;
end;
begin
readln(n);
writeln(' so nguyen to be hon hoac bang n la'); {a}
for i:=1 to n do
if ktnt(i)=0 then writeln(i);
writeln('so nguyen to nho nhat khong be hon n');
o:=n;
while o>0 do
begin
if ktnt(o)=0 then
begin
write(o);
break;
end;
o:=o+1;
end;
writeln('cặp số nguyên tố là hai số nguyên lẻ liên tiếp nhỏ hơn hoặc bằng n');
o:=0;
o:=1;
d:=0;
for i:=o+2 to n do
begin
if ktnt(i)=0 then
begin
d:=d+1;
write(i,' ');
if d<2 then continue;
end;
d:=0;
writeln;
end;
readln;
end.
#include <bits/stdc++.h>
using namespace std;
string st, a[1000];
int d,i,dem,kt,j,ln;
char x;
int main()
{
freopen("charhz.inp","r",stdin);
freopen("charhz.out",'"w",stdout);
cin>>st;
d=st.length();
a[1]=st[0];
dem=1;
for (i=0; i<d; i++)
{
kt=0;
for (j=1; j<=dem; j++)
if (a[j]==st[i]) kt=1;
if (kt==0)
{
dem++;
a[dem]=st[i];
}
}
ln=0;
for (i=1; i<=dem; i++)
{
dem=0;
for (j=0; j<=d-1; j++)
if (a[i]==st[j]) dem++;
if (ln<dem)
{
ln=dem;
x=a[i];
}
}
cout<<x<<" "<<ln;
return 0;
}
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
bool isPrime(int n) {
if (n <= 1) {
return false;
}
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
int main() {
// Mở file đầu vào
ifstream fin("TIMNT.INP");
// Mở file đầu ra
ofstream fout("TIMNT.OUT");
int n;
fin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
fin >> a[i];
}
for (int i = 0; i < n; i++) {
if (isPrime(a[i])) {
fout << a[i] << " ";
}
}
// Đóng file
fin.close();
fout.close();
return 0;
}