I don't get what is wrong with my program

So the exercise that i have wants me to find how many numbers are missing from the telephone number from 0 to 9 and which numbers are these.Also the telephone number cannot have more than 10 numbers. For example:
Input
3
0631562976
0426578943
0126456788
Output

2
4 8
1
1
2
3 9
The problem is i don't get why my program does not work properly.It seems fine to me and i think it should work.Is there something missing?
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
  #include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
int T;
cin >> T;
while (T--)
{
string s1;
cin >> s1;
vector<int>myvector;
for ( int  i = 0; i <= 9; i++)
{
    int  count  = 0;
    for ( int  j = 0; j < s1.size(); j++)
    {
        if ( i == s1[j])
        {
            break;
        }
        else
        {
           count++;
        }
        if ( count == s1.size())
        {
            myvector.push_back(i);
        }
        }
    }
    cout << myvector.size() << endl;
    for ( int  i = 0; i < myvector.size(); i++)
    {
        cout << myvector[i] << " ";
    }
    cout <<  endl;
}
    return 0;
}
You are attempting to compare ints with chars on line 20. 5 is not the same as '5'. Change line 20 to
if ( i == s1[j] - '0' )
since (for example) '5' -'0' will give 5.

Your code is almost impossible to read because the indenting is inconsistent, and almost impossible to run because there are no prompts to input any data.
οκ now i get it thank you. I thought the numbers in a string were supposed to be the same with normal numbers.
Topic archived. No new replies allowed.