在条件表达式中(如while、if语句的条件部分),不允许直接进行变量初始化并同时使用该变量进行比较。C++语法规则禁止在条件判断中同时进行变量声明和比较操作。
int numJewelsInStones(string jewels, string stones) {
// write code here
int count=0;
while ((size_t pos=jewels.find_first_of(stones))!=string::npos) {
count++;
}
return count;
}
};