diff --git a/src/Task1/task1.cpp b/src/Task1/task1.cpp index 9fb7ff4..a4d20d5 100755 --- a/src/Task1/task1.cpp +++ b/src/Task1/task1.cpp @@ -1,26 +1,76 @@ #include using namespace std; +map variables; + int solve(int n, vector arr){ int answer=0; // Start your code here + vector instruction ; + + for (int i=0; i> word) { + instruction.push_back(word); + } + + for (int j=1; j>n; - // cin.ignore(); - // vector arr(n); - // for(int i=0;i>n; +// // cin.ignore(); +// // vector arr(n); +// // for(int i=0;i NOTE: Comment main function and uncomment below line to verify your code -// #include "../../include/test1_cases.h" \ No newline at end of file +#include "../../include/test1_cases.h" \ No newline at end of file diff --git a/src/Task2/task2.cpp b/src/Task2/task2.cpp index e0056ee..af9ad3d 100755 --- a/src/Task2/task2.cpp +++ b/src/Task2/task2.cpp @@ -1,6 +1,17 @@ #include +#include +#include using namespace std; +bool secondSort(const pair &p1, const pair &p2) +{ + if (p1.second == p2.second){ + return (p1.first < p2.first) ; + } + else{ + return (p1.second > p2.second); + } +} class Solution { private: @@ -8,39 +19,113 @@ class Solution { vectorv,ans1,ans2,ans3; // v is the vector that user inputs void solve_task1(){ // solve task1 and save the answer in ans1 + set a; + for (auto i: v){ + a.insert(i); + } + for (auto i: a){ + ans1.push_back(i); + } } void solve_task2(){ // solve task2 and save the answer in ans2 + vector> a ; + for (int i=0; i q; + vector> a ; + for (int i=0; i a){ + n = length; + v = a; + solve_task1(); + solve_task2(); + solve_task3(); + } string FINDMATCH(string path){ // complete this function to read file, compare with ans1, ans2, ans3 + vector binFile ; + int length = 0; + ifstream binaryFile; + binaryFile.open("../../" + path, ios::in | ios::binary) ; + binaryFile.seekg(0, ios::end) ; + length = (int)binaryFile.tellg(); + binaryFile.seekg(0, ios::beg) ; + while (binaryFile.tellg() < length){ + unsigned int x; + binaryFile.read((char*)&x, sizeof(unsigned int)) ; + binFile.push_back(x); + } + binaryFile.close(); + // and return the answer + if (ans1 == binFile){ + binFile.clear() ; + return ("TASK1"); + } + else if (ans2 == binFile && v.size()%2 == 0){ + binFile.clear() ; + return ("TASK2"); + } + else if (ans3 == binFile && v.size()%2 == 0){ + binFile.clear() ; + return ("TASK3"); + } + else{ + binFile.clear() ; + return ("NOTFOUND"); + } } }; -int main(){ - vectora{5,7,6,5,2,1,4,0,1,3}; - string paths[]={ - "missing_files/missing1.bin", - "missing_files/missing2.bin", - "missing_files/missing3.bin", - "missing_files/missing4.bin", - }; - // Intialize your solution object here +// int main(){ +// vectora{5,7,6,5,2,1,4,0,1,3}; +// string paths[]={ +// "missing_files/missing1.bin", +// "missing_files/missing2.bin", +// "missing_files/missing3.bin", +// "missing_files/missing4.bin", +// }; +// // Intialize your solution object here +// Solution solution(a.size(), a) ; +// // Make a for loop to go through paths array and call FINDMATCH function - // Make a for loop to go through paths array and call FINDMATCH function +// for (auto path: paths){ +// cout< NOTE: Comment main function and uncomment below line to verify your code -// #include "../../include/test2_cases.h" \ No newline at end of file +#include "../../include/test2_cases.h" \ No newline at end of file