Pascal: var n:integer; f:boolean; begin f:=false; repeat write ('N = '); readln (n); until (n>=1000) and (n<=9999); while (not f) and (n<>0) do begin if n mod 10 = 4 then f:=true; n:=n div 10; end; if f then writeln ('YES') else writeln ('NO'); end.
C++: #include <iostream> using namespace std;
int main() { int n; bool f = false; while (n<1000 || n>9999) { cout <<"N = "; cin >>n; } while (!f && n!=0) { if (n%10==4) f = true; } if (f) cout <<"YES" <<endl; else cout <<"NO" <<endl; return 0; }
var n:integer;
f:boolean;
begin
f:=false;
repeat
write ('N = ');
readln (n);
until (n>=1000) and (n<=9999);
while (not f) and (n<>0) do
begin
if n mod 10 = 4 then f:=true;
n:=n div 10;
end;
if f then writeln ('YES') else writeln ('NO');
end.
C++:
#include <iostream>
using namespace std;
int main()
{
int n;
bool f = false;
while (n<1000 || n>9999)
{
cout <<"N = ";
cin >>n;
}
while (!f && n!=0)
{
if (n%10==4)
f = true;
}
if (f)
cout <<"YES" <<endl;
else cout <<"NO" <<endl;
return 0;
}