Вводится число int Если в числе есть 4 (например 1943), выводит YES Иначе NO Код #include <iostream> using namespace std; int main() { int n, x, flag; cin >> n; do { x = n % 10; n /= 10; if (x == 4) { flag = 1; } } while (x != 0); if (flag == 1) { cout << "YES"; } else { cout << "NO"; } } C #include <iostream> using namespace std; int main() { int n, x, flag; cin >> n; do { x = n % 10; n /= 10; if (x == 4) { flag = 1; } } while (x != 0); if (flag == 1) { cout << "YES"; } else { cout << "NO"; } }
#include <iostream> using namespace std; int main() { int n, x; bool flag = false; cin >> n; if (n < 0) { n = -n; } do { x = n % 10; n /= 10; if (x == 4) { flag = true; } } while (n != 0); if (flag) { cout << "YES"; } else { cout << "NO"; } return 0; } Код #include <iostream> using namespace std; int main() { int n, x; bool flag = false; cin >> n; if (n < 0) { n = -n; } do { x = n % 10; n /= 10; if (x == 4) { flag = true; } } while (n != 0); if (flag) { cout << "YES"; } else { cout << "NO"; } return 0; }