title: What's the problem with the code below?
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  using namespace std;
  int main(void)
  {
      int i, s, g;
      vector&lt;int&gt; a;
      cin &gt;&gt; s;
      for(i=1;i&lt;=s;i++)
      {
          g = s;
  
          if(g&lt;10) a.push_back(g);
          else {
              vector&lt;int&gt; temp;
              while(g &gt; 0)
              {
  
                  int k = g % 10;
                  g = g / 10;
                  temp.push_back(g);
              }
              for(int j=temp.size();j&gt;0;j--)
              {
                  a.push_back(temp[j]);
              }
          }
      }
      cout &lt;&lt; a[s-1] &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>What is wrong with the code above ? It doesn't give me the appropriate results.</p>
  
  <p>The vector a is supposed to hold the values from 1, 2, 3...up to s such that a = 12345..910111213... and print to output a[s]. Ex if s=15 a=123456789101112131415 and a[15] = 2 . </p>
  
  <p>If someone could tell me what's the problem </p>