当前位置:网站首页>7-16 find the set of integers that meet the given conditions
7-16 find the set of integers that meet the given conditions
2022-07-03 14:14:00 【Big fish】
Given no more than 6 The positive integer A, Consider from A The beginning of the continuum 4 A digital . Please output all non repeating numbers composed of them 3 digit .
Input format :
Enter... On one line A.
Output format :
The output satisfies the conditions 3 digit , From small to large , Each row 6 It's an integer . Integers are separated by spaces , But there should be no extra spaces at the end of the line .
sample input :
2
sample output :
234 235 243 245 253 254
324 325 342 345 352 354
423 425 432 435 452 453
523 524 532 534 542 543
No arrays
#include <stdio.h>
void myprint(int n);
int main()
{
int x,y;// Lower and upper limits
int i, j, k;// Loop variable
int n = 1;// Line feed counter
scanf("%d", &x);// Enter the minimum number
y=x+4;
for (i = x; i < y; i++)// Determine the first number subscript
{
for (j = x; j < y; j++)// Determine the second number subscript
{
for (k = x ; k < y; k++)// Determine the third number subscript
{
if (i != j && j != k && k != i) // If the three subscripts are not equal to each other, output
{
printf("%d%d%d", i, j, k);
myprint(n);// Newline function
n++;// Counter
}
}
}
}
return 0;
}
void myprint(int n)
{
if (n % 6 == 0)
{
printf("\n");// Change careers after six
}
else
{
printf(" ");// If you are dissatisfied, output spaces
}
}
Using arrays
#include <stdio.h>
void myprint(int n);
int main()
{
int a[4];// Save consecutive numbers
int x;// The smallest number
int i, j, k;// Loop variable
int n = 1;// Line feed counter
scanf("%d", &x);// Enter the minimum number
for (i = 0; i < 4; i++) // Save number
{
a[i] = i + x;
}
for (i = 0; i < 4; i++)// Determine the first number subscript
{
for (j = 0; j < 4; j++)// Determine the second number subscript
{
for (k = 0 ; k < 4; k++)// Determine the third number subscript
{
if (i != j && j != k && k != i) // If the three subscripts are not equal to each other, output
{
printf("%d%d%d", a[i], a[j], a[k]);
myprint(n);// Newline function
n++;// Counter
}
}
}
}
return 0;
}
void myprint(int n)
{
if (n % 6 == 0)
{
printf("\n");// Change careers after six
}
else
{
printf(" ");// If you are dissatisfied, output spaces
}
}
边栏推荐
- Generate directories from web content
- Exercise 8-2 calculate the sum and difference of two numbers
- Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
- protobuf与grpc
- JS input number and standard digit number are compared. The problem of adding 0 to 0
- Analysis of the characteristics of page owner
- Solve the problem of dormitory router campus network sharing login
- 剑指 Offer 28. 对称的二叉树
- QT learning 24 layout manager (III)
- Print. JS -- web page file printing
猜你喜欢
QT learning 21 standard dialog box in QT (Part 2)
UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料
【吉林大学】考研初试复试资料分享
Concat and concat_ Ws() differences and groups_ Use of concat() and repeat() functions
玖逸云黑免费无加密版本源码
Vite project commissioning
信创产业现状、分析与预测
Programmable logic device software testing
[email protected] Nanoparticles) | nano metal organic framework carry"/>
Metal organic framework material zif-8 containing curcumin( [email protected] Nanoparticles) | nano metal organic framework carry
Understanding of closures
随机推荐
“又土又穷”的草根高校,凭什么被称为“东北小清华”?
1px problem of mobile terminal
Solution to failure or slow downloading of electron when electron uses electron builder to package
Redis: operation command of string type data
Too many files with unapproved license
QT learning 21 standard dialog box in QT (Part 2)
Understanding of closures
npm install卡住与node-npy的各种奇怪报错
28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
Page generation QR code
Exercise 8-7 string sorting
牛客网:过河卒
MIL-100( Fe) 包裹小分子阿司匹林形成[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)
QT learning 22 layout manager (I)
Exercise 10-3 recursive implementation of exponential functions
JS new challenges
concat和concat_ws()区别及group_concat()和repeat()函数的使用
7-10 calculate salary
MongoDB数据库入门的常用命令
[ACNOI2022]猜数