I'm using Xcode for mac and Codeblocks for windows.
The txt file have 60 lines, "char char float float" each (I show you a example after de code), I want my program to return some of these lines.
Can anyone help me?
Thank you all!!
#include <iostream>
#include <fstream>
#include <cmath>
#define HEIGHT 60
#define WIDTH 4
using namespace std;
int main()
{
float a, b, l, p_cc, m_se,p_l, r_tc, k_tc, m_cv_max, sumdif;
char marca[61], modelo[61];
int kcv[61], mcv[61];
a=1.16;
b=0.87;
l=11.5;
p_cc=696;
m_se=1450;
p_l=780;
r_tc=((l-2)/(2*l-8))*l*(p_cc+acos(-1)*a*b*p_l); //CALCULO DE Rtc
k_tc=((l-6)/(2*l-8))*l*(p_cc+acos(-1)*a*b*p_l); //CALCULO DE Ktc
m_cv_max=48500-(k_tc+r_tc+m_se); //CALCULO DE Mcv,max
cout<<"Mcv,max: "<<m_cv_max<<endl;
ifstream file;
file.open("arquivo.txt");
if (file.is_open())
{
for (int i=0; i<60; ++i){
file>>marca[i]>>modelo[i]>>kcv[i]>>mcv[i];
if ((kcv[i]>=k_tc) && (mcv[i]<=m_cv_max)){
sumdif=((kcv[i]-k_tc)+(m_cv_max-mcv[i]));
cout<<marca[i]<<"\t"<<modelo[i]<<"\t"<<kcv[i]<<"\t"<<mcv[i]<<"\t"<<sumdif<<endl;
}
}
}
return 0;
}
The txt file are like:
MERCEDES-BENZ Axor_2544 14192 8808
VOLVO VM_4x2T 10050 5950
VOLVO FM11_6x2T 14100 8900
VOLVO FM11_4x2T 8600 7400
VOLVO FMX13_6x4T 13350 9650
...more 55 lines...

New Topic/Question
Reply



MultiQuote




|