Ok i have this problem: if doesn't want to work and i dont know why.
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.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("file.in");
ofstream g("file.out");
int minim,x,maxim,i,n;
f>>n;
f>>maxim;
minim=maxim;
for(i=2;i<=n;i++){
f>>x;
if(minim > x)x=minim;
if(maxim < x)x=maxim;
}
g << "min=" << minim;
g << "\n" << "max=" << maxim;
f.close();
g.close();
return 0;
}
The problem is "if" doesn't work at all.
srry for bad english
Aucun commentaire:
Enregistrer un commentaire