fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int values[] = { 4, 4, 3, 3, 4 };
  7.  
  8. for (int i = 0; i < 5; i++)
  9. {
  10. int currentValue = values[i];
  11. static int previousValue = currentValue;
  12. printf("Value: %d Change: %d\n", currentValue, currentValue - previousValue);
  13. previousValue = currentValue;
  14. }
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0s 4632KB
stdin
Standard input is empty
stdout
Value: 4 Change: 0
Value: 4 Change: 0
Value: 3 Change: -1
Value: 3 Change: 0
Value: 4 Change: 1