dat file problem

So we are going through a .dat file and the file has student ids and grades. Where I am having trouble is the fact we are also supposed ot get the average of the grades but subtract the highest and lowest grades from the average. Here is what I have so far.

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
#include<fstream>
#include<iostream>
using namespace std;
int main ()
{
    int id, score, max, min, count;
    ifstream fin;
    fin.open("quizzes.dat");
    fin>>id>>score;
    start=id;
    end=id;
    fin>>id>>score;
    while(!fin.eof())
    {
        if(id==end+1)
            end=id;
        else
        {
            if(start<end)
                cout<<start<<"-"<<end<<endl;
            else
                cout<<start<<"-"<<end<<endl;
            start=id;
            end=id;
             }
        fin>>id>>score;
    }
    if(start<end)
        cout<<start<<"-"<<end<<endl;
    else
        cout<<end<<endl;
return 0;
}
Topic archived. No new replies allowed.