Since you didn't provide any code, I decided to try it myself. Here's what I came up with. Maybe it'll give you some hints as to what you did wrong.
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <sstream>
auto split(std::string str, char delimiter)
{
std::vector<std::string> output;
std::stringstream ss(str);
for(std::string str; std::getline(ss, str, delimiter);)
output.push_back(str);
return output;
}
int main()
{
std::ifstream in("textfile");
std::string content;
std::vector<std::string> vec_content;
std::vector<int> converted_content; //Converted from string to int
for(std::string line; std::getline(in, line);)
{
content.append(line);
content.append(" ");
}
vec_content = split(content, ' ');
for(auto it = std::begin(vec_content); it != std::end(vec_content); it++)
converted_content.push_back(std::stoi(*it));
std::cout << "Max value: " << *std::max_element(std::begin(converted_content), std::end(converted_content)) << std::endl;
std::cout << "Min value: " << *std::min_element(std::begin(converted_content), std::end(converted_content)) << std::endl;
std::cout << "Odd numbers: ";
for(auto it = std::begin(converted_content); it != std::end(converted_content); it++)
{
if(*it%2)
std::cout << *it << " ";
}
std::cout << std::endl << "Even numbers: ";
for(auto it = std::begin(converted_content); it != std::end(converted_content); it++)
{
if(!(*it%2))
std::cout << *it << " ";
}
std::cout << std::endl;
return 0;
}
Example text file:
1 2 3 4 5
-92 1034 90000 62
-1 -2 -85 8
Output:
Max value: 90000
Min value: -92
Odd numbers: 1 3 5 -1 -85
Even numbers: 2 4 -92 1034 90000 62 -2 8