• Дано четырёхзначное число, определить:
    1. Входит ли в него цифра 4.

Ответы 1

  • 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;}
  • Добавить свой ответ

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years