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,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.
#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.
var a:array[1..1000] of integer;
i,n,d,max:integer;
begin
write('n = ');readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' = ');readln(a[i]);
if a[i] mod 2 <> 0 then d:=d+1;
end;
max:=a[1];
for i:=2 to n do
if a[i] > max then max:=a[i];
writeln('Co ',d,' so le');
write('So lon nhat la ',max);
readln
end.
#include <iostream>
using namespace std;
int main()
{
int t,m,n,ucln;
cout<<"Nhap n="; cin>>n;
cout<<"Nhap m="; cin>>m;
t=m%n;
while (t!=0)
{
t=n%m;
n=m;
m=t;
}
ucln=n;
cout<<ucln;
return 0;
}
#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;
}
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.