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.
const
fi='sochinhphuong.inp';
fo='sochinhphuong.out';
var f,g:text;n:longint;
function scp(n:longint):boolean;
begin
if (sqr(trunc(sqrt(n)))=n) then exit (true);
exit (false);
end;
begin
assign(f,fi);reset(f);
assign(g,fo);rewrite(g);
readln(f,n);
if scp(n) then writeln(g,'yes') else
writeln(g,'no');
close(f);close(g);
end.
uses crt;
var n,i,kt,j,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
writeln('Cac so nguyen to trong khoang tu 2 toi ',n,' la: ');
for i:=2 to n do
begin
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;
writeln;
writeln('Cac so chinh phuong trong khoang tu 0 toi ',n,' la: ');
for i:=0 to n do
if trunc(sqrt(i))=sqrt(i) then write(i:4);
writeln;
writeln('Cac so hoan hao trong khoang tu 1 toi ',n,' la: ');
for i:=1 to n do
begin
t:=0;
for j:=1 to i-1 do
if i mod j=0 then t:=t+j;
if t=i then write(i:4);
end;
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln(t);
readln;
end.
var tam,a,b,i:integer;
begin
write('a = ');readln(a);
write('b = ');readln(b);
if a < b then
begin
tam:=a;
a:=b;
b:=tam;
end;
for i:=a to b do
if sqrt(i) = trunc(sqrt(i)) then write(i:10);
readln;
End.
Program HOC24;
var d,N,i: integer;
t: longint;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
t:=0; d:=0;
for i:=1 to n do
begin
t:=t+a[i];
if a[i]>0 then d:=d+1;
end;
writeln('Tong day so la: ',t);
write('Co ',d,' so nguyen duong');
readln
end.
Câu 1:
uses crt;
var n,i,t1,t2:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t1:=0;
t2:=0;
for i:=1 to n do
begin
t1:=t1+i;
if i mod 2=0 then t2:=t2+i;
end;
writeln('Tong cac so tu 1 den ',n,' la: ',t1);
writeln('Tong cac so chan tu 1 den ',n,' la: ',t2);
readln;
end.
Câu 2:
uses crt;
var a,b,i,bcnn:longint;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
bcnn:=a*b;
for i:=a*b-1 downto 1 do
if (i mod a=0) and (i mod b=0) then
begin
if bcnn>i then bcnn:=i;
end;
writeln(bcnn);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int n,x,i,cnt,res;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>cnt;
for(i=0;i<n;i++)
{
cin>>x;
if(x%cnt==0) res++;
}
cout<<"so luong phan tu chia het cho "<<cnt<<" la: "<<res;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
const int gh=1000;
int n,x,i,cnt,res,dem[gh];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>cnt;
for(i=0;i<n;i++)
{
cin>>x;
if(x%cnt==0) { res++; dem[res]=x;}
}
cout<<"so luong phan tu chia het cho "<<cnt<<" la: "<<res;
cout<<"\n"<<"cac phan tu do la: "<<"\n";
for(i=1;i<=res;i++)
cout<<dem[i]<<" ";
return 0;
}
// đây mới đúng mik đọc lỗi đề nha bạn!!
Program HOC24;
var p,q,i,d: integer;
begin
write('Nhap p: '); readln(p);
write('Nhap q: '); readln(q);
d:=0;
for i:=p to q do if sqr(trunc(sqrt(i))) = i then d:=d+1;
write('Co ',d,' so chinh phuong');
readln
end.