Algorithm Analysis
Let be a three-digit number. Then:
the number of hundreds equals ;
the number of tens equals ;
the number of units equals .
It remains to calculate and print the product .
Algorithm Implementation
Read the input data.
scanf("%d", &n);
Calculate the digit of hundreds , tens , and units .
a = n / 100; b = n / 10 % 10; c = n % 10;
Calculate and print the product of the digits of the number.
res = a * b * c; printf("%d\n", res);
Java Implementation
import java.util.*; public class Main { public static void main(String []args) { Scanner con = new Scanner(System.in); int n = con.nextInt(); int a = n / 100; int b = n / 10 % 10; int c = n % 10; int res = a * b * c; System.out.println(res); con.close(); } }
Python Implementation
n = int(input()) a = n // 100 b = n // 10 % 10 c = n % 10 res = a * b * c print(res)