File problems

I'm trying to make a code that reads numbers (between 1 and 500) from a file named: numere.txt and writes in the numere.out file the biggest 2 digit number and how many times it appears and the smallest 2 digit number and how many times it appears.I wrote this code and i just cant understand what's wrong with it?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<iostream>
#include<fstream>
#include<conio.h>
#include<math.h>
using namespace std;
int a[501],b[501],n,i,x,maxc=0,minc=0;
int main()
{int max=9,min=100;
 ifstream f("numere.txt");
 ofstream g("numere.out");
 while(!f.eof())
{
    f>>x;
    if((x>9)&&(x<100))
   { 
     if(x<min)  min=x; a[min]=0;
     if(x==min) a[min]++; 
     if(x>max)  max=x; b[max]=0;
     if(x==max) b[max]++;  
   }
   
} 
  for(i=1;i<=500;i++)
 {     
  g<<max<<" "<<b[max];
  g<<endl;
  g<<min<<" "<<a[min];
 }    
f.close();
g.close();     
      
     
   
      getch();
      return 0;
}
if(x<min) min=x; a[min]=0; is your problem.
a[min] = 0 happens regardless of whether x<min. Use {}
Topic archived. No new replies allowed.