Please help with language translating

Write your question here.
Hello everyone,
I just started learning C++. I studied other language like python, C# in the past.
But C++ is quite different.
could any one help explain following code in daily language?
 
  if(!vis[i] && g[x][i] == 1 && Ty[f][i] != n)


vis [i] is an array loaded with default value , g is 2d array, I dont understand what !vis[i] means and what this if statement actually means.

Thanks!
if not vis[i] and g[x][i] is equal to 1 and Ty[f][i] is not equal to n
Last edited on
does it mean
vis[i] !=1 and g[x][i] !=1 and ty[f][i] !=n ?
I am confused. vis[i] is supposed to return a value, what does the "!" do and what is the return value for !vis[i]?
Thanks.
Last edited on
Yes, && is the sign for and. You can even replace && with and in the code if you want.

If vis[i] is an integer then !vis[i] is more like vis[i] != 0 vis[i] == 0. If vis[i] is a bool you should think of it as the opposite. True becomes false, and false become true.

Not sure if I am responsible for g[x][i] !=1. I accidentally wrote "g[x][i] is not equal to 1" at first but later changed it. In your original post had it as == (equal to) so I guess that's how it should be.
Last edited on
! is logical not (vs bitwise not, which is something else entirely).
c++ zero is false, else true. you see this shortcut more than anything else in c++, if(x) means if x is not zero, or if(!x) means if x IS zero.

putting that and the above together...

if vis[I] = 0 and g[x][I] is 1 and ty[f][I] is not equal to n


Last edited on
Thank you for your replies!
These helped me a lot !
Topic archived. No new replies allowed.