#include #include #include #include #include #include #include using namespace std; vector fixedvector; //Prime function bool isPrime(int num){ bool flag=true; for(int i = 2; i <= num / 2; i++) { if(num % i == 0) { flag = false; break; } } return flag; } // // Exctracting Integer numbers from a given file void extractIntegerNumbers(string str) { stringstream ss; ss << str; string temp; int found; vector v1; vector v2; while (!ss.eof()) { ss >> temp; if (stringstream(temp) >> found) v1.push_back(found); } // First elimination of 0,1,2 if(v1.size()==1){ if(v1[0]==1||v1[0]==0){ fixedvector.push_back(v1[0]); } if(v1[0]==2){ fixedvector.push_back(0); } for (int i = 2; i <=v1[0]/2; i++) { if (v1[0] % i == 0) fixedvector.push_back(v1[0]); } } // //2nd elimination for lines after first line and + " 0,1,2 " if(v1.size()>1){ for(int n=0;n2) for (int i = 2; i < v1[n]; i++){ if (v1[n] % i == 0){ v2.push_back(v1[n]); break; } } } double max = *max_element(v2.begin(), v2.end()); fixedvector.push_back(max); } } //Main function int main(){ int count1=0; string line; ifstream file("D:\\data.txt");// location of data file while (getline(file, line)){ //line numbers count1++; } string array[count1]; file.clear();//opening file again file.seekg(0, file.beg); int p=0; while (getline(file, line)){// getting numbers line by line into an array array[p]=line; p++; } string str; for(int j=0;j