Algorithm Analysis
The input number can be negative. A number is single-digit if .
Algorithm Implementation
Read the input number .
scanf("%d", &n);
Print the response.
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
n = int(input()) if n > -10 and n < 10: print("Ok") else: print("No")