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.
var
i,n,a,s,d:integer;
s1:lonint;
begin
write(' nhap a : ); readln(a);
s1:=0;s:=0;
while a <> 0 then
begin
s:= s + a mod 10;
a:= a div 10;
n:= n +s;
inc(d);
if s1 = 0 then s1:= s1 + s else
s1:= s1 * 10 + s;
s:=0;
end;
writeln(' chu so :',d);
writeln(' tong : ',n);
write(' dao nguoc: ',s1);
readln
end.
Câu 1:
uses crt;
var n,i,dem,j,kt1,kt2,a,b,kt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
dem:=0;
if n mod 2=1 then
begin
a:=2;
b:=n-a;
kt:=0;
for i:=2 to trunc(sqrt(b)) do
if b mod i=0 then kt:=1;
if kt=0 then inc(dem);
end
else begin
for i:=2 to n div 2 do
begin
a:=i;
b:=n-i;
kt1:=0;
kt2:=0;
for j:=2 to trunc(sqrt(a)) do
if a mod j=0 then kt1:=1;
for j:=2 to trunc(sqrt(b)) do
if b mod j=0 then kt2:=1;
if (kt1=0) and (kt2=0) then inc(dem);
end;
end;
writeln('So cach phan tich ',n,' thanh tong hai so nguyen to la: ',dem);
readln;
end.
Câu 2:
uses crt;
var n,x:integer;
{-----------------ham-kiem-tra-nguyen-to-----------------}
function ktnt(x:integer):boolean;
var kt:boolean;
i:integer;
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;
end;
{---------------ham-kiem-tra-so-doi-xung---------------}
function ktdx(x:integer):boolean;
var kt:boolean;
d,i:integer;
st:string;
begin
str(x,st);
d:=length(st);
kt:=true;
for i:=1 to d do
if st[i]<>st[d-i+1] then
begin
kt:=false;
break;
end;
if kt=true then ktdx:=true
else ktdx:=false;
end;
{--------------chuong-trinh-chinh---------------}
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until n>0;
if (ktnt(n)=true) and (ktdx(n)=true) then writeln(n,' la so nguyen to doi xung')
else writeln(n,' khong la so nguyen to doi xung');
x:=n+1;
repeat
x:=x+1;
until (ktnt(x)=true) and (ktdx(x)=true);
writeln('So nguyen to doi xung nho nhat lon hon ',n,' la: ',x);
readln;
end.
Cau 1:
Câu 2:
#include <bits/stdc++.h>
using namespace std;
long long n;
int main()
{
cin>>n;
if (n>0 && n%5==0) cout<<"Phai";
else cout<<"Khong phai";
}
#include <bits/stdc++.h>
using namespace std;
long long a,b,t,i;
int main()
{
cin>>a>>b;
t=0;
for (i=a; i<=b; i++)
if ((i%3==0) or (i%5==0)) t=t+i;
cout<<t;
return 0;
}
Bài 2:
#include <bits/stdc++.h>
using namespace std;
long long x,y;
int main()
{
cin >>x>>y;
cout<<x<<" "<<y;
swap(x,y);
cout<<x<<" "<<y;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,t,dem1,t1:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do
if a[i]>0 then write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Trung binh cua day la: ' ,t/n:4:2);
t1:=0;
dem1:=0;
for i:=1 to n do
if a[i]>0 then
begin
t1:=t1+a[i];
inc(dem1);
end;
writeln('Trug binh cac so duong la: ',t1/dem1:4:2);
readln;
end.
uses crt;
var a,b,i,x,y,n,m:integer;
st1,st2,st3,st4:string;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
str(a,st1);
str(b,st2);
st3:='';
for i:=length(st1) downto 1 do
st3:=st3+st1[i];
st4:='';
for i:=length(st2) downto 1 do
st4:=st4+st2[i];
val(st3,x,y);
val(st4,n,m);
writeln('So doi xung cua ',a,' la: ',x);
writeln('So doi xung cua ',b,' la: ',n);
writeln('Tong hai so doi xung cua ',a,' va ',b,' la: ',x+n);
readln;
end.