Ariana
uh
Ariana
/warns Averager
Anonymous
Guys can we convert this code to O(n) instead if O(n^2)
Anonymous
https://ideone.com/7BBDwK
Ariana
the time complexity of a algorithm is fixed
Ariana
also what are you trying
Anonymous
Any data structures or anything else can we applied so that it reduced to O(n)
Ariana
huh
Anonymous
Rose?
Mihail
?
Akshay
Anyone help me to do circular boundary setting using GPS coordinates Arduino program
MᏫᎻᎯᎷᎷᎬᎠ
klimi
🐰🐾 سمیه
Isaac
Hello freinds in my following codes ?
klimi
hi
BinaryByter
🙄
Isaac
// main.cpp
#include <iostream>
#include "../include/helper.hpp"
// #include "../in"
using std::cout;
using std::endl;
using std::endl;
int main(int argc, char const *argv[])
{
if(argc < 3 || argc > 3 || helper::isNumber(argv[1]) != (true) ||
(argv[2] != "true" && argv[2] != "false")) {
cout << "COMMAND_OPTION_ERROR: the command app command requires two options" << endl;
}
else if (helper::isNumber(argv[1])){
/* code */
}
int choice = 0;
// switch (choice)
// {
// case 1:
// /* code */
// break;
//
// default:
// break;
// }
// int choice
return 0;
}
Mihail
I'd much rather not see the helper.cpp tbh
Mihail
Pastebin it first
Isaac
Mihail
Isaac
Let me paste it first and send the paste bin link
Isaac
#include "../include/helper.hpp"
#include "../include/class/vertex.hpp"
#include <string>
using std::cout;
using std::endl;
using std::string;
using std::cout;
using std::clog;
using std::cin;
using std::cerr;
using std::vector;
using std::fstream;
using std::getline;
using std::istringstream;
using std::exception;
using std::ostringstream;
using std::ifstream;
using std::to_string;
using std::setw;
struct helper::GraphInfos
{
std::string verticesString;
// read as string matrix
matrix<std::string> graphMatrix;
bool isCostMatrix;
};
template < class T >
void helper::displayMatrix( std::vector <T> inRow){
for(auto const & val : inRow){
// gabarit 10
cout << setw(10);
cout << val;
}
}
template < class T >
void helper::displayMatrix( matrix < T > inMatrix)
{
for(auto const & row : inMatrix){
for(auto const & val : row){
// gabarit 10
cout << setw(10);
cout << val ;
}
cout << endl << endl;
}
cout << __func__ << " says " << " goodBuye " << endl;
}
// util
bool helper::isNumber(const std::string& s)
{
std::string::const_iterator it = s.begin();
while (it != s.end() && isdigit(*it))
++it;
return !s.empty() && it == s.end();
}
int helper::indexOf(row< Vertex<std::string>*> vectorOfString, Vertex<std::string>* vertex)
{
int outIndex = -1;
int size = vectorOfString.size();
for(int i = 0; i < size; i++){
if(*vectorOfString.at(i) == *vertex){
outIndex = i;
break;
}
}
return outIndex;
}
matrix<double> helper::multiply(matrix<double> inLeftMatrix, matrix<double> inRightMatrix)
{
matrix<double> outMatrix;
int size = inLeftMatrix.size();
double tmpSum = 0;
for(int i = 0; i < size; i++)
{
row<double> tmpRow;
for(int j = 0; j < size; j++, tmpSum = 0)
{
for(int k = 0; k < size; k++)
tmpSum += inLeftMatrix[i][k]*inRightMatrix[k][j];
tmpRow.push_back((bool)tmpSum);
}
outMatrix.push_back(tmpRow);
}
return outMatrix;
}
//
// This function check if two nodes are directly connected
bool helper::isConnected( matrix<double> inMatrix, int inNodeA, int inNodeB)
{
return (bool) inMatrix[inNodeA][inNodeB];
}
// check if there is a path between two node
bool existPath( matrix<double> inMatrix, int inNodeA, int inNodeB )
{
matrix<double> tmp = inMatrix;
int size = inMatrix.size();
// check the way using a theoreme of adjacencyMatrix power
for( int i = 0; i < size-1; i++)
{
if(helper::isConnected(tmp, inNodeA, inNodeB))
return true;
tmp = helper::multiply(tmp, inMatrix);
helper::displayMatrix(tmp);
}
return false;
}
// inFileNumber is the number of test file
// isCostMatrix makes to know if matrix is costed or not
helper::GraphInfos readGraphInfo(int inFileNumber, bool isCostMatrix)
{
matrix<string> tmpMatrix;
string line;
string token;
// for knowing a size of the matrix
int matrixSize = 0;
// used to known if we are readind the first line or not
bool isFirstLine = true;
string verticesString;
// local GraphInfo var that will be returned
helper::GraphInfos gInfos;
ostringstream oss;
oss << inFileNumber;
string str("../var/data/input" + oss.str() + ".txt");
row<string> tmp;
// ifstream ifs;
ifstream ifs(str);
// check for opening of the file
if(!ifs){
throw "INPUT_ERROR: The input file number " + to_string(inFileNumber) + " is unavailable";
}
Isaac
👆helper.cpp
Isaac
When I compile de helper.cpp file I get this error
Isaac
./include/helper.hpp:23:1: error: expected unqualified-id before ‘using’
using matrix = std::vector<std::vector<T>>;
^
../include/helper.hpp:25:1: error: expected unqualified-id before ‘using’
using row = std::vector<T>;
^
Dima
Probably missing template
BinaryByter
i hate reading bad code
BinaryByter
that wasn't pstebinded
BinaryByter
Fuck off xD
Thespartann
Dima
Ew, that was webcpp ad
Isaac
Everyone started somewhere so your insults will be welcome
Isaac
https://pastebin.com/cuawmP7a
BinaryByter
BinaryByter
dafaq is this meme?
Isaac
https://pastebin.com/KzWDPX1A
BinaryByter
BinaryByter
undefined behaviour
Isaac
I have forget to remove it it is for degugging
Mihail
Mihail
More importantly which c++ version
BinaryByter
BinaryByter
though such things should be 11 already 🤔
BinaryByter
MVE is required
Isaac
I run this g++ -c helper.cpp -o helper.o --std=c++11
Isaac
Isaac
BinaryByter
Mihail
Also
Mihail
#noendl
Mihail
Might want to have a look at these
14•08
Mihail
Mihail
No
Isaac
all is good now when i use -std=c++17 option
BinaryByter
okay
Mihail
Nice
Isaac
Anonymous
That's good
BinaryByter
Why, or how ?
the compiler uses variable names with __ internally
BinaryByter
(the standard library too)
Mihail
Isaac
Mihail
Yes exactly
BinaryByter
BinaryByter
Mihail
Mihail
(I think)
BinaryByter
no
BinaryByter
the standard library uses __