Outside the interval#8615

Outside the interval (Editorial)

Let's combine the conditions x < a and x > b using the or operator.

Algorithm implementation

Read the input data.

scanf("%d %d %d", &x, &a, &b);

Print the answer depending on whether the number is outside or inside the interval .

if (x < a || x > b)
  printf("OUT\n");
else
  printf("IN\n");

Java implementation

import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
    Scanner con = new Scanner(System.in);
    int x = con.nextInt();
    int a = con.nextInt();
    int b = con.nextInt();
    if (x < a || x > b) 
      System.out.println("OUT");
    else
      System.out.println("IN");
    con.close();
  }
}

Python implementation

Read the input data.

x, a, b = map(int,input().split())

Print the answer depending on whether the number is outside or inside the interval .

if x < a or x > b:
  print("OUT")
else:
  print("IN")