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.
Bài 1
Var s,i:integer;
tb:real;
Begin
Write('Nhap n = ');readln(n);
i:=1;
s:=0;
While i<=n do
Begin
s:=s+i;
i:=i+1;
End;
tb:=s/n;
Writeln('Tong la ',s);
Write('Trung binh la ',tb:10:2);
Readln;
End.
Bài 2
Var i,n,souoc:integer;
Begin
Write('Nhap n = ');readln(n);
i:=1;
While i <= n do
Begin
i:=i + 1;
If n mod i = 0 then souoc:=souoc + 1;
End;
If souoc = 1 then write(n,' la so nguyen to')
Else write(n,' khong la so nguyen to');
Readln;
End.
Program hotrotinhoc;
var s: string;
t,c,i: byte;
begin
write('Nhap s:'); readln(s);
t:=0;
for i:=1 to length(s) do
if s[i] in ['1'..'9'] then
begin
val(s[i],c);
t:=t+c;
end;
write(t);
readln
end.
Thu gọn
uses crt;
var i,j,kt:integer;
begin
clrscr;
for i:=100 to 1 do write(i:4);
writeln;
for i:=2 to 100 do
begin
kt:=0;
for j:=2 to trunc(sqrt(i)) do
if i mod j=0 then kt:=1;
if kt=0 then write(i:4);
end;
readln;
end.
uses crt;
var i,n,kt:integer;
begin
clrscr;
readln(n);
kt:=0;
for i=2 to trunc(sqrt(n)) do
if n mod i=0 then kt:=1;
if (kt=0) and (n>1) then write('phai')
else write('Khong phai');
readln;
end.
Var i,n,souoc:integer;
Begin
While n <= 1 do
Begin
Write('Nhap n = ');readln(n);
End;
For i:=1 to n do
If n mod i = 0 then souoc:=souoc+1;
If souoc = 2 then write(n,' la so nguyen to')
Else write(n,' khong la so nguyen to');
Readln;
End.
uses crt;
var n,i,kt,j:integer;
begin
clrscr;
readln(n);
i:=1;
while (i<n) do
begin
i:=i+1;
kt:=0;
for j:=2 to i-1 do
if i mod j=0 then kt:=1;
if kt=0 then write(i:4);
end;
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t,kt,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cua day so la: ',t);
kt:=0;
for j:=2 to trunc(sqrt(t)) do
if t mod j=0 then
begin
kt:=1;
break;
end;
if kt=0 then writeln(t,' la so nguyen to')
else writeln(t,' khong la so nguyen to');
readln;
end.
Cậu ơi sai khúc write('A[',i,']='); readln(a[i]); rồi nó cứ bị sao sao á
uses crt;
var a:array[1..100]of integer;
i,n,t,kt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so ban vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cac so vua nhap la: ',t);
if t>=2 then
begin
kt:=0;
for i:=2 to trunc(sqrt(t)) do
if t mod i=0 then
begin
kt:=1;
break;
end;
if kt=0 then writeln(t,' la so nguyen to')
else writeln(t,' khong la so nguyen to');
end
else writeln(t,' khong la so nguyen to');
readln;
end.
Câu 2:
uses crt;
var x,y:int64;
begin
clrscr;
readln(x,y);
writeln(x+y);
readln;
end.
in ra tất cả các số nt họ hàng hay chỉ 2 số liền kề nhau??
ngồi vắt óc mãi mới ra