package com.study.demo; import java.util.Scanner; public class Demo4 { public static void main(String [] args) { Scanner input = new Scanner(System.in); System.out.println("口令"); int n = input.nextInt(); int a = n % 10; int b = n / 10 % 10; int c = n / 100 % 10; System.out.println("个位数是:" + a); System.out.println("十位数是:" + b); System.out.println("百位数是:" + c); System.out.println("程序结束"); } }
/////////////////////////////////////////////////////////////
int a,b请用表达式判断b不是a的因子
package com.study.demo; import java.util.Scanner; public class Demo5 { public static void main(String [] args) { Scanner input = new Scanner(System.in); System.out.println( "请输入a的值:" ); int a = input.nextInt(); System.out.println( "再请输入b的值:" ); int b = input.nextInt(); if ( a % b == 0 ) { System.out.println( "a和b是因子关系,YES" ); } else { System.out.println( "a和b不是因子关系,NO" ); } } } |