C++ 如何检查向量或数组中两个不同或相同的元素是否相邻?
我想知道如何检查两个数字或元素在向量中是否相邻 以下是我迄今为止编写并尝试的代码:C++ 如何检查向量或数组中两个不同或相同的元素是否相邻?,c++,c,numbers,C++,C,Numbers,我想知道如何检查两个数字或元素在向量中是否相邻 以下是我迄今为止编写并尝试的代码: // Check stack postfix, to see if operator needs to be pushed on for (int it = 0; it < postfixstack.size(); it++) { int count = 0; // keeps track of how many numbers
// Check stack postfix, to see if operator needs to be pushed on
for (int it = 0; it < postfixstack.size(); it++)
{
int count = 0; // keeps track of how many numbers
// If number, continue, else....do something?
if (isdigit(it))
{
count++;
continue;
}
else
// do something if element is not a number
}
//检查堆栈后缀,查看是否需要推送运算符
for(int it=0;it
我在使用sstream标题时运气不错你是说像
std::nexture\u-find
?nexture\u-find做什么?我对向量函数有点陌生。我只知道一些基本知识,比如push_back和cbeginasuming postfix stack.size()>0,你需要对它进行一次完整性检查+1if(postfix stack[it]==postfix stack[it+1])
正确,我只是查找了相邻的_findon和@TheFloatingBrain Yes correct向量中已经有元素了。虽然不必是相同的数字,但可以是不同的数字。@user110182抱歉,我以为您想检查例如vec[0]=2;vec[1]=2//