#include #include #include #include #include using namespace std; vector > triangle_structure(500,vector (500,-1)); int count_l=0; bool isPrime(int num){ if (num <= 3) { return num>1; } if (num % 2 == 0 || num % 3 == 0) { return false; } for (int i = 5; i * i <= num; i = i + 6) { if (num % i == 0 || num % (i + 2) == 0) return false; } return true; } void create_triangle(){ fstream inputFile("data.txt"); string line; int count_w=0; while(getline(inputFile,line)){ string words; stringstream ss(line.c_str()); while(getline(ss,words,' ')) { if(!isPrime(stoi(words))) { triangle_structure[count_l][count_w] = stoi(words); } else{ triangle_structure[count_l][count_w] = -1; } count_w++; } count_w=0; count_l++; } } int main() { create_triangle(); bool fullPrimeLine=true; for(int i=count_l-2;i>=0;i--) { for(int j=0;j*rightChild){ *root = (*root)+(*leftChild); } else if (*rightChild>*leftChild){ *root = (*root)+(*rightChild); } else{ if(*rightChild != -1){ *root = (*root)+(*rightChild); } else{ for(int k=0;k