I a new c++ programmer, and i started to solve the SPOJ online challenges just practising , and because of my few experiance.. it gives me wrong answers alwayes.

See the Challenge here.

My Code :

#include<iostream>
#include <vector>
using namespace std;


int reverse(int input)
{
    int last_digit;
    int reversedNum = 0;
        while (input != 0) {
            last_digit = input % 10;
            reversedNum = reversedNum * 10 + last_digit;
            input = input / 10;
        }
        return reversedNum;
}

bool check(int input)
{
        if (reverse(input) == input) {
            return false;
        }
        else
        {
            return true;
        }
}


int main()
{
        vector<int> myvector;
        int numberOfTestCases;
        cin >> numberOfTestCases;
            for (int i = 0; i < numberOfTestCases; i++) {
                int num;
                cin >> num;
                myvector.push_back(num);
                }
            for (vector<int>::iterator it = myvector.begin() ; it != myvector.end(); ++it)
            {

                int num = *it;
                if (num > 1000000) {
                    cout << "number must less than 1000000" << endl;
                }
                else
                {
                    do {
                        num++;
                    } while (check(num));
                    cout << num << endl;
                }
            }return 0;
}

in program execution:
input 2 for no. of test cases
input 808 the 1st test case
input 2133 the 2nd test case
the output
818
2222

but it gives me that is a wrong answer, and i can't determine why, or what i missed from requiremnets,
can any one help.. Thanks.

Check it out. For some numbers like 101,reverse(110) returns 11. So your reverse function isn't completely correct.

what i missed from requiremnets

Something you certainly missed, the requirements seem to state that:
... For a given positive integer K of not more than 1000000 digits ...

Also, in general, you are not supposed to output anything which is not mentioned in the requirements (I'm referring to the line #45 (cout << "number must less ... )).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.