acDream


私信TA

用户名:acDream

访问量:31995

签 名:

欢迎光临CSDN博客https://blog.csdn.net/acDream_

等  级
排  名 138
经  验 7289
参赛次数 4
文章发表 72
年  龄 0
在职情况 学生
学  校 黑龙江工商学院
专  业 软件工程

  自我简介:

欢迎光临CSDN博客https://blog.csdn.net/acDream_

解题思路:

注意事项:不用排序,题目说要排序坑死了

参考代码:

public class 排列 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			int N = in.nextInt();
			while (N != 0) {
				int[] nums = new int[4];
				for (int i = 0; i < nums.length; i++) {
					nums[i] = in.nextInt();
				}
				int[][] numsprintf = new int[4][6];
				int q = 0;
				for (int i = 0; i < nums.length; i++) {
					int w = 0;
					for (int j = 0; j < nums.length; j++) {
						if (nums[j] != nums[i]) {
							for (int k = 0; k < nums.length; k++) {
								if (nums[k] != nums[j] && nums[k] != nums[i]) {
									for (int z = 0; z < nums.length; z++) {
										if (nums[z] != nums[j] && nums[z] != nums[i] && nums[z] != nums[k]) {
											numsprintf[q][w++] = (int) (Math.pow(10, 3) * nums[i]
													+ Math.pow(10, 2) * nums[j] + Math.pow(10, 1) * nums[k]
													+ Math.pow(10, 0) * nums[z]);
										}
									}
								}
							}
						}
					}
					q++;
				}
				for (int i = 0; i < numsprintf.length; i++) {
					for (int j = 0; j < numsprintf[i].length; j++) {
						if (j == numsprintf[i].length - 1) {
							System.out.print(numsprintf[i][j]);
						} else {
							System.out.print(numsprintf[i][j] + " ");
						}
					}
					if (i != numsprintf.length - 1)
						System.out.println();
				}
				if (N != 1) {
					System.out.println("\n");
				} else {
					System.out.println();
				}
				N--;
			}
		}
	}

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

我也才发现,裂开
2021-04-15 10:13:16
  • «
  • 1
  • »