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.
#include <bits/stdc++.h>
using namespace std;
string n;
int d;
int main()
{
cin>>n;
d=n.length();
cout<<d;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
string n;
int main()
{
cin>>n;
d=n.length();
ln=48;
nn=57;
for (i=0; i<=d-1; i++)
{
ln=max(ln,int(n[i]));
nn=min(nn,int(n[i]));
}
cout<<char(ln)<<" "<<char(nn);
return 0;
}
uses crt;
var n,i,t:int64;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<1000000000);
t:=0;
for i:=1 to n-1 do
if n mod i=0 then t:=t+i;
if t=n then writeln(n,' la so hoan hao')
else writeln(n,' khong la so hoan hao');
readln;
end.
uses crt;
var n,i:longint;
kt:boolean;
begin
clrscr;
readln(n);
if (n<2) then writeln('Nhap lai')
else
begin
kt:=true;
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then
begin
kt:=false;
break;
end;
if kt=true then writeln('la so nguyen to')
else writeln('khong la so nguyen to');
end;
readln;
end.
uses crt;
var a,b:longint;
Begin
clrscr;
Writeln('Nhap a,b=');
Readln(a,b);
writeln('tich hai so la : a*b=',a*b);
writeln('thuong hai so la :a/b=',a/b);
Readln;
End.
uses crt;
var a:array[2..1000000]of longint;
n,i,k,t,dem:longint;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (1<n) and (n<=1000000);
for i:=2 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
t:=0;
dem:=0;
for i:=2 to n do
if a[i] mod k=0 then
begin
t:=t+a[i];
inc(dem);
end;
writeln('Tong cac so chia het cho ',k,' la: ',t);
writeln('So phan tu chia het cho ',k,' la: ',dem);
readln;
end.
Câu 1:
Program hotrotinhoc;
var i,n: longint;
x,tl,tc,min,max,k: integer;
begin
write('Nhap so chu so : '); readln(k);
write('Nhap so nguyen N : '); readln(n);
max:=0; min:=99999; tl:=0; tc:=0;
while n<>0 do
begin
x:=n mod 10;
if max<x then max:=x;
if min>x then min:=x;
if x mod 2<>0 then tl:=tl+x;
if x mod 2=0 then tc:=tc+x;
x:=x div 10;
end;
writeln('Chu so lon nhat la : ',max,' ; ',' Chu so be nhat la : ',min);
writeln('Tong cac chu so la chu so le la :',tl);
write('Tong cac chu so la chu so chan la :',tc);
readln
end.
Bài 1: Sửa đề: Dòng 3: Tổng các chữ số là chữ số chẵn trong N
uses crt;
var n,k,i,x,max,min,t,t1:integer;
a:array[1..4]of integer;
st:string;
begin
clrscr;
write('n='); readln(n);
if n>0 then
begin
str(n,st);
k:=length(st);
if (2<k) and (k<5) then
begin
{------------------------dong-1------------------------}
for i:=1 to k do
val(st[i],a[i],x);
max:=a[1];
min:=a[1];
for i:=1 to k do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('chu so lon nhat cua ',n,' la: ',max);
writeln('chu so nho nhat cua ',n,' la: ',min);
{----------------------dong-2------------------------}
t:=0;
for i:=1 to k do
if a[i] mod 2<>0 then t:=t+a[i];
writeln('tong cac chu so la chu so le trong ',n,' la: ',t);
{---------------------dong-3-------------------------}
t1:=0;
for i:=1 to k do
if a[i] mod 2=0 then t1:=t1+a[i];
writeln('tong cac chu so la chu so chan trong ',n,' la: ',t1);
end
else writeln('vui long nhap lai');
end
else writeln('vui long nhap lai');
readln;
end.
Bài 2:
uses crt;
var n,i,t,d,y,kt,kt1:integer;
a:array[1..3]of integer;
st:string[3];
begin
clrscr;
write('n='); readln(n);
if (100<=n) and (n<=999) then
begin
str(n,st);
d:=length(st);
{--------------------------dong-1-------------------}
t:=0;
for i:=1 to d do
begin
val(st[i],a[i],y);
t:=t+a[i];
end;
writeln('tong cac chu so cua so ',n,' la: ',t);
{-------------------------dong-2---------------------}
kt:=0;
for i:=1 to d do
if a[i] mod 2=0 then
begin
kt:=1;
write(a[i]:4);
end;
if kt=0 then writeln('KHONG CO');
{-----------------------dong-3----------------------}
writeln;
kt1:=0;
for i:=1 to d do
if a[i] mod 2=1 then
begin
kt1:=1;
write(a[i]:4);
end;
if kt1=0 then writeln('KHONG CO');
end
else writeln('vui long nhap lai');
readln;
end.
viết chương trình nhập vào 1 số nguyên từ 1 đến 100 sao cho cứ 10 số thì xuống dòng
=> Program bai1;
var i:byte;
Begin
for i:=1 to 100 do
begin
write(i:3);
if i mod 10=0 then writeln;
end;
Readln
End.
Program hotrotinhoc;
var i,n,s,k,max,n1: longint;
begin
write('Nhap N='); readln(n);
max:=0; n1:=n;
while n<>0 do
begin
k:=n mod 10;
s:=s*10+k;
n:=n div 10;
if k>max then max:=k;
end;
writeln('Chu so lon nhat cua so tu nhien vua nhap la :',max);
If s=n1 then write('La so doi xung') else write('Khong phai so doi
xung');
readln
end.
uses crt;
var n,i,d,x,ln,kt:word;
st:string;
a:array[1..100]of integer;
begin
clrscr;
write('nhap n='); readln(n);
str(n,st);
d:=length(st);
for i:=1 to d do
val(st[i],a[i],x);
ln:=0;
for i:=1 to d do
if ln<a[i] then ln:=a[i];
writeln('chu so lon nhat trong so ',n,' la: ',ln);
{-----------------------kiem-tra-doi-xung----------------------------}
kt:=0;
for i:=1 to d do
if a[i]<>a[d+1-i] then kt:=1;
if kt=0 then writeln('day la so doi xung')
else writeln('day khong la so doi xung');
readln;
end.