I have encounter a horrible situation. I usually use visual code to edit my code, also compile and execute in it(F5). But I found vscode is too smart or ignore some warning message for me. And output the right answer, which also work fine in Ideone. But in window cmd or dev C++ my code can't output anything, just return a big number.
And I find some situation will occur the thing I mention above.
The code like this
for (i = 0; i < g.size(); i++)
{
int source;
int dest;
int minWeight = 999;
for (j = 0; i < g[j].size(); j++)
{
// no edge, come to next condition
if (!g[i][j])
continue;
if (g[i][j] < minWeight)
{
source = i;
dest = j;
minWeight = g[i][j];
}
}
if
updateGroup(index, index[source], index[dest]);
else
updateGroup(index, index[source], index[dest]);
}
You may found that the second for loops have wrong condition statement, it should change j = 0; i < g[j].size(); j++
to j = 0; j < g[i].size(); j++
So I wonder to know
-
Are there any way let my vscode more strict?
-
Why it still can output right answer in vscode and ideone?
-
How to avoid or be easier to found where my code wrong when this kind of no message error?
Really hope someone can help me, and appreciate all of your suggestion!!
Aucun commentaire:
Enregistrer un commentaire