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,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.
Bài 1:
uses crt;
var cd,cr,i,j:integer;
begin
clrscr;
write('chieu dai='); readln(cd);
write('chieu rong='); readln(cr);
if (cd>0) and (cr>0) and (cd>=cr) then
begin
for i:=1 to cr do
begin
for j:=1 to cd do
write('*');
writeln;
end;
end
else writeln('vui long nhap lai');
readln;
end.
Bài 2:
uses crt;
var a,s,dem:integer;
begin
clrscr;
s:=0;
dem:=0;
repeat
write('nhap so a:'); readln(a);
s:=s+a;
dem:=dem+1;
until a=0;
writeln('tong cua cac so da nhap la: ',s);
writeln('trung binh cong cua cac so da nhap la: ',s/dem:4:2);
readln;
end.
Bài 3:
uses crt;
var i:integer;
begin
clrscr;
writeln('bang tinh can bac 2 cua 100 so nguyen duong dau tien la: ');
for i:=1 to 100 do
begin
write('can bac 2 cua ',i,' la: ');
writeln(sqrt(i):4:2);
end;
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n;
int main()
{
cin>>n;
if (n%2==0) cout<<"Chan";
else cout<<"Le";
return 0;
}
uses crt;
var a:array[1..350]of integer;
n,i,t,max,t1:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{------------------------------cau-a----------------------------}
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('tong cac phan tu vua nhap la: ',t);
{------------------------------cau-b----------------------------}
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln('so lon nhat cua day la: ',max);
writeln('vi tri cua no lan luot la: ');
for i:=1 to n do
if max=a[i] then write(i:4);
{------------------------------cau-c----------------------------}
writeln;
writeln('cac so chia het cho 3 co trong day la: ');
t1:=0;
for i:=1 to n do
if a[i] mod 3=0 then
begin
write(a[i]:4);
t1:=t1+a[i];
end;
{------------------------------cau-d---------------------------}
writeln;
writeln('tong cac so chia het cho 3 co trong day la: ',t1);
readln;
end.
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.
n = int(input("Nhập vào số nguyên bất kỳ")) for i in range (1, n + 1): print(i)
TK
Program hotrotinhoc_hoc24;
var i,n,d: integer;
begin
write('Nhap n='); readln(n);
d:=0;
for i:=1 to n do if i mod 2=0 then d:=d+1;
writeln('Co ',d,' so chan tu 1 den n');
write('Cac so chan do la : ');
for i:=1 to n do if i mod 2=0 then write(i,' ');
readln
end.
Bài 1:
uses crt;
var n,i,dem,maxd,vt,vt1,vt2,vt3,maxa,dem1:integer;
a,b,c,d,e,f,g:array[1..100]of integer;
mind,mina:int64;
begin
clrscr;
repeat
write('n='); readln(n);
if (n<=0) or (n>100) then writeln('nhap lai');
until (0<n) and (n<=100);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{--------------------------so-hang-duong-----------------------}
dem:=0;
for i:=1 to n do
if a[i]>0 then
begin
inc(dem);
b[dem]:=a[i];
end;
maxd:=0;
for i:=1 to dem do
if maxd<b[i] then maxd:=b[i];
vt:=0;
for i:=1 to n do
if maxd=a[i] then
begin
vt:=vt+1;
c[vt]:=i;
end;
writeln('so hang duong lon nhat cua day la: ',maxd);
writeln('vi tri cua no lan luot la: ');
for i:=1 to vt do
write(c[i]:4);
writeln;
mind:=maxint;
for i:=1 to dem do
if mind>b[i] then mind:=b[i];
vt1:=0;
for i:=1 to n do
if mind=a[i] then
begin
inc(vt1);
d[vt1]:=i;
end;
writeln('so hang duong nho nhat cua day la: ',mind);
writeln('vi tri cua no lan luot la: ');
for i:=1 to vt1 do
write(d[i]:4);
{------------------------so-hang-am--------------------------}
writeln;
dem1:=0;
for i:=1 to n do
if a[i]<0 then
begin
inc(dem1);
e[dem1]:=a[i];
end;
maxa:=e[1];
for i:=1 to dem1 do
if maxa<e[i] then maxa:=e[i];
vt2:=0;
for i:=1 to n do
if maxa=a[i] then
begin
inc(vt2);
f[vt2]:=i;
end;
writeln('so hang am lon nhat cua day la: ',maxa);
writeln('vi tri cua no lan luot la: ');
for i:=1 to vt2 do
write(f[i]:4);
writeln;
mina:=maxint;
for i:=1 to dem1 do
if mina>e[i] then mina:=e[i];
vt3:=0;
for i:=1 to n do
if mina=a[i] then
begin
inc(vt3);
g[vt3]:=i;
end;
writeln('so hang am nho nhat cua day la: ',mina);
writeln('vi tri cua no lan luot la: ');
for i:=1 to vt3 do
write(g[i]:4);
readln;
end.
Bài 2:
uses crt;
var a,vt:array[1..10]of integer;
i,x,dem:integer;
begin
clrscr;
for i:=1 to 10 do
begin
write('a[',i,']='); readln(a[i]);
end;
write('nhap x='); readln(x);
dem:=0;
for i:=1 to 10 do
if a[i]=x then
begin
inc(dem);
vt[dem]:=i;
end;
if dem=0 then writeln('khong co gia tri ',x,' trong day')
else
begin
writeln('vi tri cua ',x,' trong day lan luot la:');
for i:=1 to dem do
write(vt[i]:4);
end;
readln;
end.
Bài 3:
uses crt;
var a:array[1..100,1..100]of integer;
n,i,j,t:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
for j:=1 to n do
begin
write('a[',i,',',j,']='); readln(a[i,j]);
end;
{----------------------------xuat-----------------------------}
writeln('ma tran ban vua nhap la:');
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j]:4);
writeln;
end;
{------------------tong-cac-phan-tu-tren-duong-cheo-chinh------------------}
t:=0;
for i:=1 to n do
for j:=1 to n do
if i=j then t:=t+a[i,j];
writeln('tong cac phan tu tren duong cheo chinh la: ',t);
readln;
end.
uses crt;
var i,n:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
if i mod 2=1 then write(i:4);
readln;
end.
cho mik hỏi mod là j v ạ