if statement doesn't work in for loop : <p>Ok i have this problem: if doesn't want to work and i dont know why.</p>

<p>The program is supposed to take from a file some numbers, first indicates the number of numbers on the second line and say what is the minimum and maximum on that line.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;


using namespace std;

int main()
{
 ifstream f("file.in");
 ofstream g("file.out");
 int minim,x,maxim,i,n;

 f&gt;&gt;n;
 f&gt;&gt;maxim;
 minim=maxim;

 for(i=2;i&lt;=n;i++){
    f&gt;&gt;x;
    if(minim &gt; x)x=minim;
    if(maxim &lt; x)x=maxim;
 }
    g &lt;&lt; "min=" &lt;&lt; minim;
    g &lt;&lt; "\n" &lt;&lt; "max=" &lt;&lt; maxim;
    f.close();
    g.close();

return 0;
}
</code></pre>

<p>The problem is "if" doesn't work at all.</p>

<p>srry for bad english</p>
