Commit 26c8b8c0 authored by Mario Bajer's avatar Mario Bajer
Browse files

fixed multi.cpp

parent db65fe2f
#include "Matrix.hpp" #include "Matrix.hpp"
bool exists(string filename){ bool existsm(string filename){
ifstream f(filename); ifstream f(filename);
return f.good(); return f.good();
} }
...@@ -40,7 +40,7 @@ int Matrix::generateMatrix(int dimension){ ...@@ -40,7 +40,7 @@ int Matrix::generateMatrix(int dimension){
this->ID = rand() % 100; this->ID = rand() % 100;
string folderpath = "Json/"; string folderpath = "Json/";
string testpath = folderpath + to_string(this->ID); string testpath = folderpath + to_string(this->ID);
while(exists(testpath)){ while(existsm(testpath)){
cout << "<p>" << "File mit ID: " << this->ID << " existiert bereits!" << "</p>"; cout << "<p>" << "File mit ID: " << this->ID << " existiert bereits!" << "</p>";
this->ID = rand() % 100; this->ID = rand() % 100;
testpath = folderpath + to_string(this->ID); testpath = folderpath + to_string(this->ID);
......
...@@ -47,6 +47,6 @@ private: ...@@ -47,6 +47,6 @@ private:
}; };
void htmlHeader(string title); void htmlHeader(string title);
bool existsm(string filename);
#endif #endif
\ No newline at end of file
...@@ -138,10 +138,34 @@ int main(){ ...@@ -138,10 +138,34 @@ int main(){
result = run(mult_strassen, matrix1, matrix2); result = run(mult_strassen, matrix1, matrix2);
cout << "debug 4"; cout << "debug 4";
result.generateMatrix(result.dim); json json3;
srand(time(NULL));
result.ID = rand() % 100;
string folderpath = "Json/";
string testpath = folderpath + to_string(result.ID);
while(existsm(testpath)){
cout << "<p>" << "File mit ID: " << result.ID << " existiert bereits!" << "</p>";
result.ID = rand() % 100;
testpath = folderpath + to_string(result.ID);
}
folderpath += to_string(result.ID) + ".json";
json3["id"] = result.ID;
json3["dimension"] = result.dim;
int size = result.dim * result.dim;
vector<int> v(result.data, result.data + size);
json3["matrix"] = v;
ofstream o;
o.open(folderpath);
o << json3 << endl;
o.close();
// result.generateMatrix(result.dim);
cout << "Resulting Matrix saved at ID: " + to_string(result.ID) << endl; cout << "Resulting Matrix saved at ID: " + to_string(result.ID) << endl;
cout << "</div>" << endl; cout << "</div>" << endl;
cout << "<a href=\"http://localhost:80/index.html\">Back to Index</a>";
cout << "</body>\n"; cout << "</body>\n";
cout << "</html>\n"; cout << "</html>\n";
return 0; return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment