uses crt;
var s:string;
function kt(s:string):boolean;
var i,dem:byte;
begin
dem:=0;
for i:=2 to length(s)-1 do
if ((s[i-1]<s[i]) and (s[i]>s[i+1])) or ((s[i-1]>s[i]) and (s[i]<s[i+1])) then
dem:=dem+1;
if dem=length(s)-2 then kt:=true else kt:=false;
end;
begin
clrscr;
write('nhap so nguyen duong: '); readln(s);
if kt(s)=true then write('so vua nhap la so don dieu') else
write('so vua nhap khong phai so don dieu');
readln;
end.
chúc bạn học tốt