One-digit number#8873

One-digit number (Editorial)

The input number can be negative. The absolute value of consists of a single digit. In other words, the inequality -9 \le n \le 9 must hold.

Algorithm implementation

Read the input value of .

scanf("%d", &n);

Print the answer.

if (n > -10 && n < 10) puts("Ok");
else puts("No");

Java implementation

import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
    Scanner con = new Scanner(System.in);
    int n = con.nextInt();
    if (n > -10 && n < 10) System.out.println("Ok");
    else System.out.println("No");
    con.close();
  }
}

Python implementation

Read the input value of .

n = int(input())

Print the answer.

if n > -10 and n < 10: print("Ok")
else: print("No")

Python implementation — 2

Read the input value of .

n = int(input())

Print the answer.

if -10 < n < 10: print("Ok")
else: print("No")