因为我觉得它可能是可能的,所以我试图摆脱光滑的衬垫.
我将把我的代码放在下面,然后尝试解释一下我想要实现的更多内容.
for (int p = 0; p < 2; p++)
{
foreach (string player in players[p])
{
if (PlayerSkills[player].streak_count *>* 0) //This line
PlayerSkills[player].streak_count++;
else
PlayerSkills[player].streak_count = 0;
}
}
Run Code Online (Sandbox Code Playgroud)
*(p == 0?>:<)根据p选择比较运算符.
当然,我写的是垃圾.但基本上我想在p == 0时使用> 0,在p >> 0时使用<0.有没有一个很好的方法来实现这一目标?
好吧,你应该使用最具可读性的东西,即使它不是一样的.那说......
// Invert the count for all but the first player and check for a positive number
if (PlayerSkills[player].streak_count * (p==0 ? 1 : -1) > 0)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
139 次 |
| 最近记录: |