过程:将当前数据与后面的数据作差比较,是否大于这个常量
const double derta = 3.0;
QVector<double> vctDat;
vctDat.reserve(7);
vctDat << 1.2 << 5.6 << 10.8 << 14.9 << 19.2 << 20.0 << 67.9;
int passCnt = 0, cmpCnt = 0;
for(int i = 0; i < vctDat.size(); ++i){
const double &tmpDat = vctDat.at(i);
for(int j = i+1; j < vctDat.size(); ++j)
{
qDebug() << "-------------------"<< tmpDat << "-"<< vctDat.at(j) << "=" << qAbs(tmpDat - vctDat.at(j));
if(qAbs(tmpDat - vctDat.at(j)) > derta){
++passCnt;
}
++cmpCnt;
}
}
if(passCnt == cmpCnt){
qDebug() << "-------------------pass" << "passCnt:" << passCnt << "cmpCnt:" << cmpCnt;
return;
}else{
qDebug() << "-------------------no" << "passCnt:" << passCnt << "cmpCnt:" << cmpCnt;
return;
}