• 11 多少个互不相同且无重复数字的三位数


    题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?
    程序分析:

    可填在百位、十位、个位的数字都是1、2、3、4。组成所有的排列后再去 掉不满足条件的排列。

    思路:
    * 1、每位数都遍历一次,就是个位出现1234,十位出现1234,百位出现1234
    * 2、去重复,个位十位百位不能相等
    * 3、复合式遍历,统计这种遍历得到了多少回

     1     public class _011PrintThreeArray {
     2 
     3     public static void main(String[] args) {
     4         printThreeArray();
     5     }
     6     
     7      
     8     private static void printThreeArray() {
     9         int count = 0;
    10         System.out.println("这样的组合有:");
    11         for (int x = 1; x < 5; x++) {
    12             for (int y = 1; y < 5; y++) {
    13                 for (int z = 1; z < 5; z++) {
    14                     if (x != y && y != z && z != x) {
    15                         count++;
    16                         
    17                         System.out.print(x * 100 + y * 10 + z+" ");
    18                     }
    19                 }
    20             }
    21         }
    22         System.out.println();
    23         System.out.println("共有" + count + "个三位数");
    24     }
    25 }
  • 相关阅读:
    linux 网络不通问题排查
    linux下挂载U盘
    git 详细教程网址
    字符串的全排列和组合算法
    D-BUS详细分析
    linux socket编程之TCP与UDP
    Linux下的 .o、.a、.so文件
    Fiddler HTTPS指南
    nm指令
    无法使用xcode打出ipa包的解决方法
  • 原文地址:https://www.cnblogs.com/liuyangfirst/p/6514305.html
Copyright © 2020-2023  润新知