当前位置:网站首页>Chapter 18: explore the wonders of the mean in the 2-bit a~b system, specify the 3x+1 conversion process of integers, specify an interval to verify the angular Valley conjecture, explore the number of
Chapter 18: explore the wonders of the mean in the 2-bit a~b system, specify the 3x+1 conversion process of integers, specify an interval to verify the angular Valley conjecture, explore the number of
2022-07-26 03:51:00 【Shares_ four】
//2 position a~b Exploration of the spectacle of the mean bit in hexadecimal
int main()
{
int a, b, c, d, e, g, i, j, p, t;
long s;
printf(" Please enter the interval of port base a,b: ");
scanf("%d, %d", &a, &b);
for (p = a; p <= b; p++)
for (j = 1; j <= p - 1; j++)
{
g = j * p + j;
s = g * g;
d = s;
e = d % p;
d = d / p;
t = 0;
while (d > 0)
{
c = d % p;
d = d / p;
if (c != e)
{
t = 1;
break;
}
}
if (t == 0)
{
printf(" stay %d In base : ", p);
for (i = 1; i <= 2; i++)
if (j < 10)
printf("%ld", j);
else
printf("[%ld]", j);
printf(" ^2=");
while (s > 0)
{
c = s % p;
s = s / p;
if (c < 10)
printf("%ld", c);
else
printf("[%ld] ", c);
}
printf("\n");
}
}
printf(" stay %d-%d We have explored the above wonders of the mean bit \n", a, b);
return 0;
}
result :
// Specify the 3x+1 The transformation process
int main()
{
long int m, n, c;
printf(" please enter an integer m: ");
scanf(" %ld", &m);
n = 0;
c = m;
printf(" %ld", m);
while (c != 1)
{
if (c % 2 == 1)
{
c = 3 * c + 1;
n++; // Odd hour , multiply 3 After add 1
printf("->%ld", c);
}
else
{
c = c / 2;
n++; // Even number , Divide 2
printf("->%ld", c);
}
if (n % 10 == 0)
printf("\n");
if (n > 10000) break;
}
if (n > 10000)
printf("\n Exceed 10000 Step has not completed the conversion .");
else printf("\n Together with %ld Step complete the conversion .\n",n);
return 0;
}
result :
// Specify an interval to verify the angular Valley conjecture
int main()
{
long a, b, c, m,m1, m2,n,max,min;
printf(" Please enter the interval limit a, b: ");
scanf ("%ld,%ld", &a, &b) ;
max=0;
min=100;
for (m=a;m<=b;m++)
{
n=0; c=m;
while (c != 1)
{
if (c % 2 == 1) // Odd hour , multiply 3 After add 1
{
c = 3 * c + 1;
n++;
}
else
{
c = c / 2;
n++; // Even number , Divide 2
}
}
if (n > max) {
max = n;
m1 = m;
} // Find the maximum value of the conversion step
if (n < min) {
min = n; m2 = m;
} // Find the minimum value of the conversion step
}
printf(" When m=%ld The maximum number of conversion steps is , Together with %ld Step through .\n",m1,max);
printf(" When m=%1d The number of conversion steps is the least , Together with %1d Step through .\n", m2, min);
return 0;
}
result :
// verification 3 Number of bit black holes
int main()
{
int i, j, n, n1, m, max;
int sub(int i);
printf(" Verify any 3 digit “ Rearrange the difference ” operation , To 495 or 0. \n");
for (max = 0, n = 100; n <= 999; n++)
{
i = n;
m = 0;
while (i != 495 && i != 0) //m Statistics are converted to 495 The number of times // Conditional discrimination
{
i = sub(i);
m++;
}
if (m > max)
{
max = m;
n1 = n;
j = i; // Maximum number of conversions max
}
}
if (j == 195)
printf(" When n=%d when , At most % d Secondary arrival 495: \n", n1, max);
if (j == 0)
printf(" When n = %d when , At most xd Secondary arrival 0: \n", n1, max);
printf(" %d", n1);
i = n1;
while (i != 495 && i != 0)
{
i = sub(i);
printf("->%d",i);
}
printf(".\n");
}
int sub(int i)
{
int p, k, j, h, max, min, a[4];
a[1] = i / 100;
a[2] = (i / 10) % 10;
a[3] = i % 10;
for (k = 1; k <= 2; k++)
for (j = k + 1; j <= 3; j++)
if (a[k] < a[j])
{
h = a[k];
a[k] = a[j];
a[j] = h;
}
max = a[1] * 100 + a[2] * 10 + a[3];
min = a[3] * 100 + a[2] * 10 + a[1];
p = max - min;
if (p < 100 && p / 10 == p % 10) p = 0;
return (p);
}
result :
// Seek 4 Number of black holes
int main()
{
int i, j, m, n, n1, max;
int sub(int i);
printf(" all 4 The number of digits is “ Rearrange the parameters ” operation , can 6194 or 0\n");
for (max = 0, n = 1000; n <= 9999; n++)
{
i = n;
m = 0;
while (i != 6174 && i != 0)
{
i = sub(i);
m++;
}
if (m > max)
{
max = m;
n1 = n;
j = i;
}
}
if (j == 6174)
printf(" \n %d when , At most %d Secondary arrival 6174: \n", n1, max);
if(j == 0)
printf(" \n %d when , At most %d Secondary arrival 0: \n", n1, max);
printf(" %d",n1);
i = n1;
while (i != 6174 && i != 0)
{
i = sub(i);
printf("->%d", i);
}
printf(".\n");
}
int sub(int i)
{
int p, k, j, h, max, min, a[5];
a[1] = i / 1000;
a[2] = (i / 100) % 10; // hold 1 digit 1 Decompose into 4 A digital
a[3] = (i % 100) / 10;
a[4] = i % 10;
for (k = 1; k <= 3; k++)
for(j = k+1;j <=4;j++)
if (a[k] < a[j])
{
h = a[k];
a[k] = a[j];
a[j] = h;
}
max = a[1] * 1000 + a[2] * 100 + a[3] * 10 + a[4];
min = a[4] * 1000 + a[3] * 100 + a[2] * 10 + a[1];
p = max - min;
if (p < 1000 && p / 100 == (p / 10) % 10 && p / 100 == p % 10)
p = 0;
return (p);
}
result :
边栏推荐
- Kbpc1510-asemi large chip 15A rectifier bridge kbpc1510
- 【Unity3d Shader】角色投影与倒影
- Introduction to UFS CLK gate
- Analysis on the infectious problem of open source license
- 【读书笔记->数据分析】BDA教材《数据分析》书籍介绍
- Matlab paper illustration drawing template issue 39 - stairs
- 全校软硬件基础设施一站式监控 ,苏州大学以时序数据库替换 PostgreSQL
- 微信小程序实现音乐播放器(5)
- Why are more and more users of Bing search?
- Opencv learning notes - edge detection and Canny operator, Sobel operator, lapiacian operator, ScHARR filter
猜你喜欢

9-20v input peak charging current 3A dual lithium switch type charging chip sc7102

Introduction to UFS CLK gate

IDEA2020.3.1不能打开(双击不能打开),但可以通过idea.bat打开。

深度学习之DAT

Idea2020.3.1 cannot be opened (double click cannot be opened), but it can be opened through idea.bat.

Opencv learning notes -- Hough transform

Navicat连接云端服务器上的MySQL数据库

【云原生】谈谈老牌消息中间件ActiveMQ的理解

The convolution kernel is expanded to 51x51, and the new CNN architecture slak counterattacks the transformer

B2B2C多商户系统功能丰富,极易二开
随机推荐
研发了 5 年的时序数据库,到底要解决什么问题?
php 查找 session 存储文件位置的方法
Basic line chart: the most intuitive presentation of data trends and changes
Find my technology | the Internet of things asset tracking market has reached US $6.6 billion, and find my helps the market develop
Div setting height does not take effect
Tf.constant usage
软考 系统架构设计师 简明教程 | 案例分析解题技巧
MySQL索引失效场景以及解决方案
Realization of online shopping mall system based on JSP
基于移位寄存器的同步FIFO
php 保存数组到文件 var_export、serialize
Dat of deep learning
【虚拟化】查看vCenter和ESXi主机的Log日志文件
Network model and protocol
5年1.4W倍,NFT OG 的封神之路|Web3专栏
[MCU simulation project] external interrupt 0 controls 8 LED flashes
6年从零开始的自动化测试之路,开发转测试我不后悔...
1311_硬件设计_ICT概念、应用以及优缺点学习小结
redis集群的三种方式
Find My技术|物联网资产跟踪市场规模达66亿美元,Find My助力市场发展