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 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.
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.
1:
uses crt;
var i,j,t,kt:integer;
begin
clrscr;
t:=0;
for i:=1 to 100 do
if i>1 then
begin
kt:=0;
for j:=2 to i-1 do
if i mod j=0 then kt:=1;
if kt=0 then t:=t+i;
end;
writeln(t);
readln;
end.
Câu 2:
*Viết chương trình:
uses crt;
var n,p,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for p:=2 to n-1 do
if n mod p=0 then t:=t+p;
writeln('Tong cac uoc that su cua ',n,' la: ',t);
readln;
end.
const fi='dayso.inp';
fo='dayso.out';
var f1,f2:text;
a:array[1..100]of integer;
st,s:string;
n,i,kt,d:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
for i:=1 to n do
begin
str(a[i],s);
st:=st+s;
end;
kt:=0;
d:=length(st);
for i:=1 to d do
if st[i]<>st[d-i+1] then kt:=1;
if kt=0 then writeln(f2,1)
else writeln(f2,0);
close(f1);
close(f2);
end.
Program HOC24;
var s,st,t: string;
a: array[1..100] of integer;
n,i: integer;
begin
write('Nhap so tu nhien n='); readln(n);
for i:=1 to n do read(a[i]); readln;
for i:=1 to n do
begin
str(a[i],t);
s:=s+t;
end;
for i:=length(s) downto 1 do st:=st+s[i];
if s=st then write(1) else write(0);
readln
end.
a)
uses crt;
var n,i,t,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
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.
b)
uses crt;
var gt:real;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
gt:=1;
for i:=1 to n do
gt:=gt*i;
writeln(gt:0:0);
readln;
end.
Bài 2:
#include<iostream>;
using namespace std;
bool shh(int a){
int u, tong = 0;
bool kq = false;
for (u = 1; u < a; u++) {
if (a % u == 0) {
tong+= u;
}
}
if (tong == u) {
kq = true;
}
return kq;
}
int main() {
int n, i, u, tong = 0, a[1000];
cout << "Nhap so phan tu: ";
cin >> n;
for (i = 1; i <= n; i++) {
cout << "Phan tu thu " << i << ": ";
cin >> a[i];
}
cout << "Cac So hoan hao:" << endl;
for (i = 1; i <= n; i++) {
if (shh(a[i]) == true) {
cout << a[i] << " ";
}
}
return 0;
}
#include<iostream>;
using namespace std;
int main() {
int i,a,b;
cout << "Nhap A,B: " << endl;
cin >> a >> b;
for (i = a; i <= b; i++) {
if ((i % 10) == (i /10)) {
cout << i << " ";
}
else if (i == 101){
cout << i;
}
}
return 0;
}
var n,k,i,j,d,tam:longint;
s,t:string;
a:array[1..7260] of byte;
begin
write('Nhap n,k:');readln(n,k);
for i:=1 to n do
begin
str(i,t);
for j:=1 to length(t) do
begin
inc(d);
val(t[j],a[d]);
end;
end;
for i:=1 to d-1 do
for j:=i+1 to d do
if a[i]>a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to d-k do
begin
str(a[i],t);
s:=s+t;
end;
write(s);
readln;
end.
Bài 1:
uses crt;
var n,kt,d,i:longint;
st:string;
begin
clrscr;
write('nhap n='); readln(n);
str(n,st);
kt:=0;
d:=length(st);
for i:=1 to d do
if (st[i]<>'4') and (st[i]<>'7') then kt:=1;
if kt=0 then write(n,' la so may man')
else write(n,' khong la so may man');
readln;
end.
Program HOC24;
var n: longint;
i,d,tg,j,m: integer;
a: array[1..10] of integer;
begin
write('Nhap n='); readln(n);
m:=0; d:=0;
while n<>0 do
begin
d:=d+1;
a[d]:=n mod 10;
n:=n div 10;
end;
if m>0 then
begin
for i:=1 to d do
for j:=i to d do
if a[i]>a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
end else
begin
for i:=1 to d do
for j:=i to d do
if a[i]<a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
end;
if m>0 then
for i:=1 to d do write(a[i]) else
begin
write('-');
for i:=1 to n do write(abs(a[i]));
end;
readln
end.