Compiled but output not coming

i tried to solve shortest road trip problem on my own but my code is not giving output and its compiled successfully
my code is https://ide.codingblocks.com/s/72931

in the while loop u also have to cin the character u are only taking input 1 time u also have to take input in while loop

i have doubt regarding cin and cin.get()


in this code when i use cin.get()
it works fine but when i use cin
it just dont give any output

beacause in the while loop u r checking the condition that ch!=ā€™\nā€™
when u do cin u cannot take new line character as input it is the functionality of cin
but through cin.get u can take input new line character

to see
just change the condition while ch!= ā€˜xā€™
abd then use cin for input like NNEWSx
u will get the ans
and see the diference between cin and cin.get

1 Like