vector<int> G[MAXN] ;
char isLeaf[MAXN] ;
int n,path;
for(int i = 0;i < n;i++) path -= isLeaf[i] = G[i].size() == 1 ;
// For循环中的代码如何工作?我对这里的多个运营商感到困惑。
答案 0 :(得分:2)
由于operator precedence and associativity,声明
path -= isLeaf[i] = G[i].size() == 1 ;
相当于:
path -= (isLeaf[i] = (G[i].size() == 1));
如果为了清楚起见将它分成多个语句,你会得到:
bool temp = (G[i].size() == 1);
isLeaf[i] = temp;
path -= isLeaf[i];