本文整理汇总了C++中Coin::updateProbablities方法的典型用法代码示例。如果您正苦于以下问题:C++ Coin::updateProbablities方法的具体用法?C++ Coin::updateProbablities怎么用?C++ Coin::updateProbablities使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coin
的用法示例。
在下文中一共展示了Coin::updateProbablities方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compare
void Coin::compare(Coin B){
//Ideal coin struct initialization
double value[4] = {.75, .835, .705, .955};
string name[4] = {"penny","nickel","dime","quarter"};
for(int i = 0; i<16; i++){
Ideal[i].Ratio = value[i/4]/value[i%4];
Ideal[i].CoinA = name[i/4];
Ideal[i].CoinB = name[i%4];
Ideal[i].Difference = abs(value[i/4]-value[i%4]);
Ideal[i].ScaledDifference = Ideal[i].Difference/((value[i/4]+value[i%4])/2);
}
double dA = diameter;
double dB = B.getDiameter();
double ratio = dA/dB;
double scaledDifference = abs(dA-dB)/((dA+dB)/2);
double sProb, rProb, aProb;
for(int i = 0; i<16; i++){
if(Ideal[i].Ratio != 1){
rProb = 1 - abs(ratio - Ideal[i].Ratio);
sProb = 1 - abs(scaledDifference - Ideal[i].ScaledDifference);
aProb = abs((rProb + sProb)/2);
updateProbablities(Ideal[i].CoinA,aProb);
B.updateProbablities(Ideal[i].CoinB,aProb);
}
}
};