Files
IT-Step/remove_digits.cpp

30 lines
689 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <iostream>
using namespace std;
int main() {
int number;
int newNumber = 0;
int multiplier = 1;
cout << "Введiть цiле число: ";
cin >> number;
int originalNumber = number;
while (number > 0) {
int digit = number % 10;
if (digit != 3 && digit != 6) {
newNumber = newNumber + digit * multiplier;
multiplier *= 10;
}
number = number / 10;
}
cout << "Введене число: " << originalNumber << endl;
cout << "Нове число (без цифр 3 i 6): " << newNumber << endl;
return 0;
}