#include #include #include #include // for isspace #include // for atoi int main(void) { cout << "In the name of Allah" << "\n" ; const int MAX = 90 ; // size of buffer char Current ; char Pre[MAX] ; int Ipre=0; char Post[MAX]; int Ipost=0; int Flag = 0 ; double FPre =0 ; double FPost=0 ; int track = 0 ; double oldFPre=0; double AvgFPost=0; int n=0; ifstream infile("delay_result.txt"); // create file for input while(infile) { while (Flag == 0 ) { infile.get(Current); Pre[Ipre++]= Current ; if (Current==' ') { Pre[Ipre] = '\0' ; FPre = atof(Pre) ; cout << FPre ; Ipre=0 ; cout << " this is a space "; Flag = 1 ; } } // EO while(Flag == 0) while (Flag == 1) { do { infile.get(Current); Post[Ipost++] = Current ; } while (Current != '\n' ); Post[Ipost] = '\0' ; FPost = atof(Post) ; cout << FPost << "\n" ; // double oldFPre=0; // double AvgFPost=0; // int n=0; if(track ==0) //comming first time { oldFPre = FPre ; track = 1; } if (oldFPre == FPre) { AvgFPost= AvgFPost + FPost ; n++ ; } else { cout << "Average=" << AvgFPost/n <<"\n" ; track = 0 ; } Ipost =0 ; Flag = 0 ; Pre[0]= '\0' ; Post[0]= '\0' ; FPre = 0 ; FPost = 0; } // EO while(Flag == 1) }/*while(infile) ends here*/ infile.close(); return 0 ; }