C++ 21 点游戏决策:优化策略,助你赢取胜利
#include
int main() {
int N;
cin >> N;
vector
int sum = 0;
for (int i = 0; i < N; i++) {
sum += cards[i];
}
int X = 21 - sum;
int greaterCount = 0;
int smallerCount = 0;
for (int i = 1; i <= 10; i++) {
if (i > X) {
greaterCount += 4;
} else if (i < X) {
smallerCount += 4;
}
}
if (greaterCount > smallerCount || greaterCount == smallerCount) {
cout << "DOSTA" << endl;
} else {
cout << "VUCI" << endl;
}
return 0;
}
原文地址: https://www.cveoy.top/t/topic/qr4D 著作权归作者所有。请勿转载和采集!