fork download
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4. #include <iostream>
  5. using namespace std;
  6. int main()
  7. {
  8. int t;
  9. scanf("%d", &t);
  10. long int k[t];
  11. for(int p=0; p<t; p++)
  12. {
  13. scanf("%ld", &k[p]);
  14. k[p]+=1;
  15. //printf("%ld",k[p]);
  16. }
  17. for(int q=0; q<t; q++)
  18. {
  19. int flag=0;
  20. do
  21. {
  22. char s[100];
  23. //itoa(k[q], s, 10);
  24. sprintf(s, "%ld", k[q]);
  25. //cout<<s;
  26. /*string t;
  27. getline(cin, t);
  28. cout<<t;*/
  29.  
  30. int l=strlen(s);
  31. //cout<<"\n l="<<l;
  32. char r[100];
  33. int i, j;
  34. //cout<<endl;
  35. for(i=l-1, j=0; i>=0; i--, j++)
  36. {
  37. r[j]=s[i];
  38. //cout<<r[j];
  39. }
  40. r[j]='\0';
  41. //cout<<"\n r="<<r;
  42. if(strcmp(s, r) == 0)
  43. {
  44. flag=1;
  45. printf("\n%s", s);
  46. }
  47. else
  48. {
  49. k[q]=atol(s);
  50. k[q]=k[q]+1;
  51. }
  52. }while(flag != 1);
  53. flag=0;
  54. }
  55. //cout<<endl;
  56. return 0;
  57. }
Success #stdin #stdout 0s 3344KB
stdin
2
808
2133
stdout
818
2222