Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Введено тризначне число. Потім ввели будь-яку цифру. Складіть алгоритм, що визначає, чи є в цьому числі дана цифра.
- #include <iostream>
- #include <ctype.h>
- #include <fstream>
- #include <string>
- #include <sstream>
- #include <list>
- #include <math.h>
- using namespace std;
- int main(void) {
- setlocale(0, "");
- int a = 0, n, r, n1;
- cout << "Введiть число: ";
- cin >> n;
- cout << "Введiть цифру: ";
- cin >> n1;
- do
- {
- r = n % 10;
- if (r == n1) {
- cout << "Є!\n";
- a = 1;
- n = 0;
- }
- n = n / 10;
- } while (n >= 1);
- if (a != 1)
- cout << "Немає!\n";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment