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.
câu 1
Program Nguyen_to;
Var n,i:integer;
Function NT(n:integer):Boolean;
Var ok: Boolean;
i: integer;
Begin ok:=true;
for i:=2 to n-1 do if (n mod i)= 0 then ok:=ok and false;
if n < 2 then NT:=false else NT:=ok;
End;
Begin Write('Nhap n: ');
Readln(n); i:=n;
Repeat i:=i+1;
Until NT(i);
Write('So nguyen to nho nhat lon hon ',n, 'la: ',i);
Readln End.
câu 2
uses crt;
const so: set of char=['0','1','2','3','4','5','6','7','8','9'];
var a:array[1..100] of integer;
st,b:string;
c,l,i,n,j:integer;
s, Max: integer;
begin clrscr;
write('Nhap xau:');
readln(st);
l:=length(st);
i:=1;
n:=0;
repeat if (st[i] in so) then begin b:='';
repeat b:=b+st[i];
inc(i);
until (not(st[i] in so)) or (i>l);
inc(n);
val(b,a[n],c);
end;
inc(i);
until i>l;
Max:=a[1];
for i:=2 to n do If Max<A[i] Then Max:=A[i];
Writeln('Phan tu lon nhat cua mang:', Max);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[100],n,i,ln,nn,vt1,vt2;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
ln=a[1];
nn=a[1];
for (i=1; i<=n; i++)
{
ln=max(ln,a[i]);
nn=min(nn,a[i]);
}
cout<<ln<<" "<<nn;
return 0;
}
Var n,i,vtl,vtn,so max,min:integer;
Begin
Write('Nhap so luong so = ');readln(n);
vtl:=0;
vtn:=0;
max:=-32768;
min:=32767;
For i:=1 to n do
Begin
Write('Nhap vao so thu ',i);readln(so);
If so > max then
Begin
Max:=so;
vtl:=i;
End;
If so < min then
Begin
Min:=so;
vtn:=i;
End;
Writeln('So lon nhat la ',max,' tai vi tri thu ',i);
Write('So nho nhat la ',min,' tai vi tri thu ',i);
Readln;
End.
#include <bits/stdc++.h>
using namespace std;
long n,i,dem,t;
int main()
{
cin>>n;
dem=0;
t=0;
for (i=1; i<=n;i++)
if (n%i==0)
{
dem++;
t=t+i;
}
cout<<dem<<" "<<t;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
readln(a[i]);
for i:=1 to n do
write(a[i]:4);
writeln;
for i:=1 to n do
if (a[i]+a[i+1] mod 10=0) then
begin
writeln(a[i],' ',a[i+1]);
writeln(i,' ',i+1);
end;
readln;
end.
uses crt;
var n,t:integer;
{------------------kiem-tra-so-nguyen-to----------------------------}
function ktnt(x:integer):boolean;
var i:integer;
kt:boolean;
begin
kt:=true;
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then
begin
kt:=false;
break;
end;
if kt=true then ktnt:=true
else ktnt:=false;
{----------------------chuong-trinh-chinh------------------------}
begin
clrscr;
t:=0;
repeat
write('Nhap n='); readln(n);
if (n mod 2=0) then t:=t+n;
until ktnt(n)=false;
writeln(t);
readln;
end.
uses crt;
var n,i,dem,j,t:integer;
kt:boolean;
begin
clrscr;
readln(n);
t:=0;
for i:=2 to n do
begin
kt:=true;
for j:=2 to i-1 do
if i mod j=0 then kt:=false;
if kt=true then
begin
write(i:4);
t:=t+i;
end;
end;
writeln;
writeln(t);
readln;
end.