当前位置:网站首页>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
}
}
边栏推荐
- 6-9 statistics of single digits (15 points)
- 战略、战术(和 OKR)
- QT learning 22 layout manager (I)
- JS Part III
- 28: Chapter 3: develop Passport Service: 11: define attributes in the configuration file, and then obtain them in the code;
- JS get DPI, PX to cm, cm to PX
- Eight sorts
- selenium 浏览器(1)
- Exercise 10-1 judge the three digits that meet the conditions
- Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material
猜你喜欢
Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
Example analysis of QT learning 18 login dialog box
QT learning 19 standard dialog box in QT (top)
Article content typesetting and code highlighting
剑指 Offer 28. 对称的二叉树
QT learning 20 standard dialog box in QT (middle)
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值
[email protected] (FE) | glycyrrhetinic acid modified metal organ"/>
Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
随机推荐
Eight sorts
UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料
MIL-100( Fe) 包裹小分子阿司匹林形成[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子
“又土又穷”的草根高校,凭什么被称为“东北小清华”?
Interface for querying IP home
Toast UI editor (editor allows you to edit your markup document using text or WYSIWYG, with syntax highlighting, scrolling synchronization, real-time preview and chart functions.)
Learn to punch in today
JVM runtime data area
Configure stylelint
剑指 Offer 28. 对称的二叉树
Invalid Z-index problem
Why don't I have a rookie medal
JS get DPI, PX to cm, cm to PX
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
MongoDB数据库入门的常用命令
jvm-运行时数据区
Exercise 10-1 calculate the sum of 1 to n using recursive functions
Exercise 9-1 time conversion