I have tried this and getting the exact numbers but I dont know why my solution is not getting accepted. I have done in C++ and this is my code
This is a modified code that takes care of extra large digits but the answer is still not accepted.
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <bits/stdc++.h>
#include<limits>
using namespace std;
int main(){
int b;
cin>>b;
int num[b];
for(int i=0;i<b;i++){
cin>>num[i];
if(num[i]>1000000){
//cout<<"Enter value less than 1000000"<<endl;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(),'\n');
//cout<<"You have entered wrong input"<<endl;
cin>>num[i];
}
}
string a[b];
for(int i=0;i<b;i++){
long numb = num[i] + 1;
if(!(numb>1000000 || num[i] <10 )){
for(int k=numb; k<1000000; k++){
stringstream ss;
ss << k;
string str=ss.str();
string ostr = str;
reverse(str.begin(), str.end());
if(ostr == str){
a[i] = ostr;
//cout<<ostr<<endl;
break;
}
}
cout<<a[i]<<endl;
}
}
}
created
last reply
- 1
reply
- 626
views
- 2
users
- 1
link