diff options
sem 8
1 files changed, 20 insertions, 0 deletions
| -rw-r--r-- | Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp | 20 |
diff --git a/Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp b/Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp new file mode 100644 index 0000000..4ae1131 --- /dev/null +++ b/Sem. 03/Tasks and Solutions/07. ContainsDigit.cpp @@ -0,0 +1,20 @@ +#include <iostream> +using namespace std; + +int main() +{ + int n, searchedDigit; + cin >> n >> searchedDigit; + + bool found = false; + while (n != 0) + { + int lastDigit = n % 10; + if (searchedDigit == lastDigit) + { + found = true; + break; + } + n /= 10; + } +}
\ No newline at end of file |
