Przeszukiwanie pliku txt - odczyt wartości MAX

0

Witam,

Piszę mały programik który ma odczytać z pliku txt wartości MAX (MAX=16, MAX=9.22) i potem obliczyć odpowiednią formułę.
Jestem początkująca z c++.
Mam problem z przeszukaniem pliku linia po linii, a dokładnie z wyszukaniem i odczytaniem wartości MAX.
Jeśli to możliwe bardzo prosiłabym o pomoc.
Format w pliku txt :

==================================================
||       Original distance between points       ||
==================================================

#DVF	Mean	SD	MeanX	SDX	MeanY	SDY	MeanZ	SDZ	Max 	MaxX	MaxY	MaxZ
0	6.34	2.94	-1.1	      1.36	0.869	        1.77	-5.52  	3.38	16	-3.91	4.88	-16

@	6.34	2.94	-1.1	    1.36	0.869  	1.77	-5.52         3.38	16	-3.91	4.88	-16

==================================================
||       Residual distance between points       ||
==================================================

#DVF	Mean	SD	MeanX	SDX	MeanY	SDY	MeanZ	SDZ	Max 	MaxX	MaxY	MaxZ
0	3.66	1.78	-0.645	0.869	 0.612	1.12	-3.05	         2.1	9.22	-2.52	3.12	-9.19

@	3.66	1.78	-0.645	0.869	0.612	        1.12	-3.05	         2.1	9.22	-2.52	3.12	-9.19

Tutaj fragment mojego kodu :

#include "stdafx.h"
#include <iostream>
#include "stdio.h"
#include <fstream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
	string contains_file;
	string line;

	ifstream newFile;
	newFile.open("TRE_10.txt");
	if(newFile.is_open() == 1)
	{
		int i=0;
		while(newFile.good())
		{
			// Read all file
			// getline(newFile, contains_file);
		    // std::cout<<contains_file<<std::endl;
			
			getline(newFile, line);
			if(line.find("MAX") != 0)
			{
			  
			  std::cout << line <<std::endl;
			}

	     	i++;
		}

	}/*else
	{
		cout<<"Error ! It can not open file.";
	}*/
	newFile.close();
	cin.get();

	// Final TRE equation 
	// double max_1 =10;
	// double max_2 = 5;
	// double tre = sqrt(max_1-max_2)*sqrt(max_1-max_2);
	std::cout <<" MAX TRE :  "<<tre<<std::endl;

	system("Pause");
	return 0;
}


 

Będę wdzięczna za każdą pomoc proszę.

dodanie znaczników <code> dla zawartości pliku - fp

2
#include <iostream>
#include <fstream>
using namespace std;
 
int main()
  {
   ifstream fs("TRE_10.txt");
   while(true)
     {
      static const char Fnd[]="\n\n@";
      const char *fnd=Fnd;
      while((fs)&&(*fnd)) if(fs.get()!=*(fnd++)) fnd=Fnd;
      double V=0;
      for(unsigned i=0;i<9;++i) fs>>V;
      if(!fs) break;
      cout<<V<<endl;
     }
   cin.get();
   return 0;
  }
0

Dzięki wielkie :)

1 użytkowników online, w tym zalogowanych: 0, gości: 1