Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

C++ Codeblocks problem, C++

views
     
TStechnosakai
post Mar 29 2015, 10:42 PM, updated 9y ago

On my way
****
Junior Member
512 posts

Joined: Mar 2010


hi there guys..
I'm using codeblocks to do my assignment for college.

There's this problem with it when I try to run the code, a pop-up would come up and states that my code (example: kruskal.exe stopped working)
but when I copy paste a program from the Internet, everything works well.

There is Avira Protection Cloud keep on popping up whenever I run my kruskal.exe program. it would ask whether I would wanna send it to the Avira cloud or not. Whatever option I choose, the program would just stop working. Even when I have disable the Avira Protection Cloud..

Can anyone tell me what's the problem here?
Seriously damn fed up with this problem.
Eventless
post Mar 30 2015, 07:35 AM

Look at all my stars!!
*******
Senior Member
2,641 posts

Joined: Jan 2003
QUOTE(technosakai @ Mar 29 2015, 10:42 PM)
There's this problem with it when I try to run the code, a pop-up would come up and states that my code (example: kruskal.exe stopped working)
but when I copy paste a program from the Internet, everything works well.
*
Based on this, the problem is with your code. Without showing your code, no one can help you.
TStechnosakai
post Mar 30 2015, 10:52 AM

On my way
****
Junior Member
512 posts

Joined: Mar 2010


so this is my code

» Click to show Spoiler - click again to hide... «



this is copied from the internet

» Click to show Spoiler - click again to hide... «


the only difference is this part

int main()
{
int V = 10; // Number of vertices in graph
int E = 16; // Number of edges in graph
struct Graph* graph = createGraph(V, E);


// add edge 0-1
graph->edge[0].src = 0;
graph->edge[0].dest = 1;
graph->edge[0].weight = 8;

// add edge 0-6
graph->edge[1].src = 0;
graph->edge[1].dest = 6;
graph->edge[1].weight = 9;

// add edge 0-9
graph->edge[2].src = 0;
graph->edge[2].dest = 9;
graph->edge[2].weight = 6;

// add edge 1-2
graph->edge[3].src = 1;
graph->edge[3].dest = 2;
graph->edge[3].weight = 16;

// add edge 1-4
graph->edge[4].src = 1;
graph->edge[4].dest = 4;
graph->edge[4].weight = 10;

// add edge 1-5
graph->edge[5].src = 1;
graph->edge[5].dest = 5;
graph->edge[5].weight = 21;

// add edge 2-3
graph->edge[6].src = 2;
graph->edge[6].dest = 3;
graph->edge[6].weight = 11;

// add edge 2-4
graph->edge[7].src = 2;
graph->edge[7].dest = 4;
graph->edge[7].weight = 20;

// add edge 3-4
graph->edge[8].src = 3;
graph->edge[8].dest = 4;
graph->edge[9].weight = 17;

// add edge 4-5
graph->edge[10].src = 4;
graph->edge[10].dest = 5;
graph->edge[10].weight = 35;

// add edge 5-6
graph->edge[11].src = 5;
graph->edge[11].dest = 6;
graph->edge[11].weight = 13;

// add edge 5-7
graph->edge[12].src = 5;
graph->edge[12].dest = 7;
graph->edge[12].weight = 33;

// add edge 5-8
graph->edge[13].src = 5;
graph->edge[13].dest = 8;
graph->edge[13].weight = 18;

// add edge 6-8
graph->edge[14].src = 6;
graph->edge[14].dest = 8;
graph->edge[14].weight = 7;

// add edge 7-8
graph->edge[15].src = 7;
graph->edge[15].dest = 8;
graph->edge[15].weight = 14;

// add edge 7-9
graph->edge[16].src = 7;
graph->edge[16].dest = 9;
graph->edge[16].weight = 45;

KruskalMST(graph);

only added the number of edges and vertices
help?

angch
post Mar 30 2015, 06:35 PM

On my way
****
Junior Member
635 posts

Joined: Jul 2006
You have 17 edges, not 16.

https://en.wikipedia.org/wiki/Zero-based_numbering
TStechnosakai
post Mar 30 2015, 11:10 PM

On my way
****
Junior Member
512 posts

Joined: Mar 2010


QUOTE(angch @ Mar 30 2015, 06:35 PM)
Already changed that. Same problem. If the edges value is wrong, it would only have a logic error no?

My problem now is the .exe file just stop running after I run the exe file.

 

Change to:
| Lo-Fi Version
0.0134sec    0.26    5 queries    GZIP Disabled
Time is now: 29th March 2024 - 07:35 AM