随笔分类 - java
摘要://find number of times each digit occur in a number import java.util.Scanner; public class Numbers { public static void main(String[] args) { int num; int[] arr = new int[10]; // we use hashing to sol
阅读全文
摘要://check whether the number is palindrome or not /* * a number is said to be palindrome if, reverse of the number is same to * that of real. for example, 121, 52025, 5885 etc.. */ import java.u...
阅读全文
摘要://print all digits of the given number import java.util.Scanner; public class Numbers { public static void main(String[] args) { int num; Scanner ip = new Scanner(System.in);...
阅读全文
摘要://print all prime numbers within a number import java.util.Scanner; public class Numbers { public static void main(String[] args) { int beg, end; Scanner ip = new Scanner(System.in); System.out.print(
阅读全文
摘要://find n'th prime number import java.util.Scanner; public class Numbers { public static void main(String[] args) { int n, count = 0, i = 2; Scanner ip = new Scanner(System.in); System.out.print("Enter
阅读全文
摘要://Generate n prime numbers import java.util.Scanner; public class Numbers { public static void main(String[] args) { int n, count = 0; Scanner ip = new Scanner(System.in); System.out.print("Enter the
阅读全文
摘要://check prime, find whether the input number is prime number or not import java.util.Scanner; public class Numbers { public static void main(String[] args) { int num; boolean...
阅读全文
摘要://find nd smallest among n numbers import java.util.Scanner; public class Numbers { public static void main(String[] args) { int n, temp, min = Integer.MAX_VALUE, secondMin = Integer.MAX_VALUE; Scanne
阅读全文
摘要://find nd greatest among n numbers import java.util.Scanner; public class Numbers { public static void main(String[] args) { int n, temp, max = Integer.MIN_VALUE, secondMax = Integer...
阅读全文
摘要://pre increment public class Sample { public static void main(String[] args) {int a, b, c, d, e; Scanner s = new Scanner(System.in); System.out.print("Enter any integer a:"); ...
阅读全文
摘要://find greatest among n numbers import java.util.Scanner; public class Numbers { public static void main(String[] args) { int n, temp, max = Integer.MIN_VALUE; Scanner ip = new Scanner(System.in); Sys
阅读全文
摘要:2 求三个数中最小值 3
阅读全文
摘要://find greatest among two numbers import java.util.Scanner; public class Numbers { public static void main(String[] args) { int num1, num2; Scanner ip = new Scanner(System.in); System.out.print("Enter
阅读全文
摘要://switch statement import java.util.Scanner; public class Sample { public static void main(String[] args) { int num; Scanner ip = new Scanner(System.in); System.out.print("Enter number between 1 to 4:
阅读全文
摘要:获取多个整数输入 获取字符串 获取多个字符串
阅读全文
摘要:public class Sample { public static void main(String[] args) { int num = 10; do { System.out.print(num + " "); } while (num != 10); } } OUTPUT: 10
阅读全文
摘要:public class Sample { public static void main(String[] args) { int num = 1; while (num <= 10) { System.out.print(num + " "); num++; } } } OUTPUT: 1 2 3 4 5 6 7 8 9 10
阅读全文