RE : Code not working on codebocks

My code is not working on codeblocks but is working on online compiler.

It shows filename.exe has stopped working without taking any input

link to code :

hey you should declare bool ar[a+1] after scaning the value of a.

If you still have any problem feel free to comment.

1 Like

I think it’s memory error because variable a holds some garbage value initially until it’s declared hence when u declare an array i.e bool ar[a+1] it exits due to failure of memory allocation. Try moving bool ar[a+1] below fastscan(a).

ohh my bad!!
thanks

Also in this code

All testcase works fine but for particulary this input it prints garbage value.

testcase :

9 10

1 2 3 4 5 6 7 8 9

1 5

5 6

6 7

5 7

9 1

1 2

2 8

2 3

3 4

2 4

Also in this code

All testcase works fine but for particulary this input it prints garbage value.

testcase :

9 10

1 2 3 4 5 6 7 8 9

1 5

5 6

6 7

5 7

9 1

1 2

2 8

2 3

3 4

2 4

I got this output by running your code-

value of node1
5 9 2 
value of node2
1 8 3 
value of node3
2 0 
value of node4
0 
value of node5
1 6 7 
value of node6
5 7 
value of node7
6 5 
value of node8
2 
value of node9
1 

I cant see any garbage value here :confused:

And what is the question? Debugging code without knowing the purpose of code is like shooting an arrow in dark.

Actually i figured out it was problem of using fastscan()
it was taking space as input when i was copying testcase .

1 Like