Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- //Compiler version g++ 6.3.0
- void findCuts(int n, int &amountOfCuts, int &smallest) {
- bool isSmallest = false;
- for (int i = 0; i <= 9; i++) {
- int newN = n;
- while (newN != 0) {
- int rem = newN % 10;
- if (rem == i) {
- if (!isSmallest) {
- isSmallest = true;
- smallest = rem;
- } else if (rem != smallest) {
- amountOfCuts += 1;
- break;
- }
- }
- newN /= 10;
- }
- }
- }
- int main() {
- int n = 911131;
- int smallest, amountOfCuts;
- smallest = amountOfCuts = 0;
- findCuts(n, amountOfCuts, smallest);
- cout << "Smallest: " << smallest << endl;
- cout << "Amount: " << amountOfCuts;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement