求符合给定条件的整数集
给定不超过6的正整数A,考虑从A开始的连续4个数字。请输出所有由它们组成的无重复数字的3位数。
输入格式:
输入在一行中给出A。
输出格式:
输出满足条件的的3位数,要求从小到大,每行6个整数。整数间以空格分隔,但行末不能有多余空格。
输入样例:
2
输出样例:
234 235 243 245 253 254
324 325 342 345 352 354
423 425 432 435 452 453
523 524 532 534 542 543
题目判定
解题程序
编译器:*
JAVAC
程序代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int i =scan.nextInt();
int[] array = new int[4];
for(int t = 0;t<4;t++)
{
array[t] = i+t;
}
for(int a =0; a<4;a++)
{
int cnt=0;
for(int b =0;b<4;b++)
{
for(int c = 0;c<4; c++)
{
if(a!=b && a!=c && b!=c)
{
System.out.print(""+array[a]+array[b]+array[c]);
cnt++;
if(cnt==6)
{
System.out.println();
}
else
{
System.out.print(" ");
}
}
}
}
}
}
}