88. Toggle Bitmask

 The class Flags is already defined with a private 8-bit variable bits, a constructor, and a getter.

Your task is to overload the bitwise NOT (~) operator so that applying ~flags returns a new Flags object with all 8 bits inverted.

In main():

  • Read an integer representing an 8-bit unsigned flag value
  • Create a Flags object using the lower 8 bits of the input
  • Apply the overloaded ~ operator
  • Print both the original input value and the toggled value in the specified format

 

Input / Output Specification

Input:
A single integer N such that 0 ≤ N ≤ 255

Output:
Print the original input and the inverted value in the format:

Input=<input_value> Toggled Input=<toggled_value>

 

Example 1

Input:

0

Output:

Input=0 Toggled Input=255 

 

Example 2

Input:

255

Output:

Input=255 Toggled Input=0 

 

Example 3

Input:

170

Output:

Input=170 Toggled Input=85

 

Constraints

  • Input value represents an 8-bit unsigned flag
  • Valid range: 0 to 255
  • Only the lower 8 bits are considered
  • Bit inversion must be limited to exactly 8 bits

 

 

 

Loading...

Input

0

Expected Output

Input=0 Toggled Input=255