当前位置:网站首页>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
}
}边栏推荐
- FPGA测试方法以Mentor工具为例
- [ACNOI2022]猜数
- 7-7 12-24 hour system
- JVM runtime data area
- Selenium browser (1)
- Redis:Redis的数据结构、key的操作命令
- 中国PETG市场预测及战略研究报告(2022版)
- js 2023. String pair equal to the target string after connection
- Exercise 6-2 using functions to sum special A-string sequences
- Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
猜你喜欢

Leetcode(4)——寻找两个正序数组的中位数

556. 下一个更大元素 III

Message subscription and publishing

Redis:字符串類型數據的操作命令

Redis: operation command of string type data

Example analysis of QT learning 18 login dialog box

JS Part 2

7-11 calculation of residential water charges by sections

Article content typesetting and code highlighting

Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
随机推荐
Solve the problem of dormitory router campus network sharing login
Exercise 8-8 moving letters
玖逸云黑免费无加密版本源码
7-10 calculate salary
泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
selenium 浏览器(1)
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
Example analysis of QT learning 18 login dialog box
QT learning 23 layout manager (II)
Exercise 10-2 recursive factorial sum
JS shift operators (< <,> > and > > >)
[clean up the extraordinary image of Disk C]
[acnoi2022] guess numbers
Message subscription and publishing
QT learning 22 layout manager (I)
C language,%d% Difference between 2D%2d%02d
Sendmail无法发送邮件及发送过慢解决
Exercise 9-1 time conversion
“又土又穷”的草根高校,凭什么被称为“东北小清华”?
叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线