x=((next - present) == 356) ? 2 : (((present - last) == 382) ? 1 : 0);
next present and last are to hold numeric values
x = (comparison_that_resolves_to_true_or_false)? value_returned_if_true : value_returned_if_false;
In your code provided x is assigned the value 2 if next is greater than present by exactly 356.
If next is any other value, x is assigned the value 1 if present is greater than last by exactly 382.
If present is any other value, x is assigned the value of 0.
in other words,
x is assigned the value 2 if next-present equals 356.
if next-present does not equal 356 then
x is assigned the value 1 if present-last equals 382.
if present-last does not equal 382 then
x is assigned the value 0.