【发布时间】:2018-06-22 14:00:47
【问题描述】:
我正在尝试检查不断变化的速度整数中的值,我要检查的值是当前值和之前的值,我有这段代码,但由于某种原因它不起作用。 我的问题是如何有效地保存不断变化的速度整数的最新 2 个值
这是我的代码
int CurrentValue; // The Integer is already defined and initialized, this is the latest value of it
int PriorValue; // this value is the one that was prior to the current one
CurrentValue = ChangingInt; // here we save the current Speed value in ChangingInt
if (CurrentValue != ChangingInt){
PriorValue = CurrentValue; /* replacing the CurrentValue value as the prior one
since it has changed according to the if statement */
}
【问题讨论】: