/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
// simulated keystrokes
// The -1 will stop the sim if no keys detected before then
// Normally, you should never get to the -1
int testcase[]={0,0,1,1,9,9,8,0,0,0,-1};
int tc=0;
int main()
{
int code, oldcode;
code=0;
oldcode=0;
do {
oldcode=code;
code=testcase[tc++]; // get keys
if (code==-1) // should never happen
{
printf("End of data\n");
break;
}
printf("Loop %d: old=%x,code=%x\n",tc-1,oldcode,code);
} while (oldcode<=code);
printf("Processing %x\n", oldcode);
return 0;
}