Script for multiplying by 2 and checking for digits

I am trying to make a script with C++ that multiplies permutations of 123567890 (no 4) by 2, and checks if the number is a permutation of 1234567890. I have made a script, but it doesn't work. Please check the script and tell me how to fix it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <random>
#include <chrono>
using namespace std;


int main() {
    int myints[] = { 5, 6, 7, 8, 9, 0, 1, 2, 3 };
    int two[] = { 1, 2, 3, 5, 6, 7, 8, 9, 0 };
    int num = 1;
    string numString;
    int numList[] = { 0 };
    int counter = 0;
    int mult = 0;
    int zero = 0;
    string numTemp;

    do {
        stringstream buffer;
        buffer << myints[0] << ' ' << myints[1] << ' ' << myints[2] << ' ' << myints[3] << ' ' << myints[4] << ' ' << myints[5] << ' ' << myints[6] << ' ' << myints[7] << ' ' << myints[8] << '\n';
        cout << buffer.str();

        numString = buffer.str();
        num = stoi(numString);

        if (zero = num % 2) {
            do {
                numList[counter] = (num / (10 ^ counter) % 10);
                counter += 1;
            } while (counter != 9);
            do {
                num *= 2;
                mult += 1;
                numTemp = to_string(num);
                if (numTemp.find(1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 != std::string::npos)) {
                    cout << "Success" << ' ' << num << " x2^" << mult;
                    return 0;
                }
            } while (num < 10000000000);
        }

    } while (std::next_permutation(myints, myints + 9));

    return 0;
}


Thank you for your assistance
You are performing an assignment on line 29, not a comparison. If you want to compare two values, use the == operator.

Line 38 doesn't do what you are intending. You will need to find each of the digits (as characters, not integers as you are currently doing) independently if you want to use find(), but I recommend just using std::is_permutation().
http://www.cplusplus.com/reference/algorithm/is_permutation/
Topic archived. No new replies allowed.