A:
===========================================
import java.util.Vector;
public class NumberComposition {
- private static Vector
nums = new Vector ();
public static void generateNumbers(){
- int num;
for(int i=1; i <= 4; i++){
- num =0;
for(int j=1; j <= 4; j++){
- for(int k=1; k <= 4; k++){
- if((i!=j) && (i!=k) && (j!=k)){
- num = i* 100 + j*10 + k;
nums.add(num);
- num = i* 100 + j*10 + k;
- if((i!=j) && (i!=k) && (j!=k)){
- for(int k=1; k <= 4; k++){
- num =0;
public static int getNumberCounter(){
- return nums.size();
public static void printNumbers(){
- for(int i=0; i < nums.size(); i++){
- System.out.print(nums.get(i) + " ");
public static void main(String[] args) {
- generateNumbers();
System.out.println("Total number: " + getNumberCounter());
printNumbers();
- int num;
==========================================
result:
Total number: 24
123 124 132 134 142 143 213 214 231 234 241 243 312 314 321 324 341 342 412 413 421 423 431 432
No comments:
Post a Comment