Vector declaration globally and in the main class
<p>I was writing a code , in which when i declare a vector globally , it gives wrong answer but when i declare it in the main function . it becomes right . so i want to know the difference between the two declarations</p>

<p>this is a code which find the min of first enteries, and 2nd min of 2nd enteries and then if min >= 2nd min print no . here i declared vector in the main class but when i declare it with my INTs declared , the site on which i was submitting gives me wrong answer.</p>

<pre><code>#include&lt;iostream&gt;
#include&lt;algorithm&gt;
#include&lt;vector&gt;
#include&lt;cstdio&gt;

using namespace std;

#define MAX 20000;
int a,b,c,d,i,z;


int main()
{
        scanf("%d %d", &amp;a, &amp;b);
        while( a!=0 &amp;&amp; b!=0)
        {
            z = MAX;
            for(i=0;i&lt;a;i++)
            {
                scanf("%d",&amp;c);
                if(z&gt;c)
                {
                    z=c;
                }
            }


            vector&lt;int&gt; v;  
            for(i=0;i&lt;b;i++)
            {
                scanf("%d",&amp;d);
                v.push_back(d);
            }
            sort(v.begin(),v.end());

            if (z &gt;= v[1])
            printf("N\n");
            else
            printf("Y\n");
        scanf("%d %d", &amp;a, &amp;b);
        }       
    return 0;
}
</code></pre>

<p>Sudhanshu</p>
