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