#include <iostream>
#include <sstream>
#include <fstream>
int main()
{
std::ifstream inputFile("input.txt");
std::string word1,word2,word3,word4,word5,line;
float price;//price take from user
std::cin >> price;
float priceFile; //price read from file
if(inputFile)
{
while(std::getline(inputFile,line) )//read line by line
{
//check if line is/isnot empty
if(!line.empty())
{
std::istringstream ss(line);
while(std::getline(ss, word1,','),//read the first word
std::getline(ss, word2,','),//read the second word
std::getline(ss, word3,','),//read the third word
std::getline(ss, word4,','),//read the fourth word
std::getline(ss, word5) )
{
std::istringstream ss2(word5);
ss2 >> priceFile;
//check
if(priceFile <= price)
{
//remove space from here if you need
std::cout<<word1 <<" "<<word2<<" "<<word3<<" "<<word4<<" "<<priceFile<<std::endl;
}
}
}
}
}
else
{
std::cout<<"Input file cannot be openede"<<std::endl;
}
}
Riga,Kraslava,Pr,15:00,11.00
Riga ,Kraslava,Pr ,18:00,11.00
Kraslava,Riga,Pr,08:00,11.00
Kraslava,Daugavpils,Ot ,10:00, 3.00
Rezekne,Riga,Tr,13:00,10.50
Dagda,Kraslava, Ce,18:00, 2.50
Riga,Ventspils, Pt,09:00 , 6.70
Liepaja,Ventspils,Pt,17:00,5.50