当前位置:网站首页>第一章:求奇因数代数和,求同吗小数和s(d, n),简化同码小数和s(d, n),拓广同码小数和s(d, n)
第一章:求奇因数代数和,求同吗小数和s(d, n),简化同码小数和s(d, n),拓广同码小数和s(d, n)
2022-07-03 19:18:00 【股_四】
//求奇因数代数和
int main()
{
int d, m, n;
long s;
printf("请输入整数n:");
scanf("%d",&n);
s = 0;
for(m = 1; m <= n; m++)
{
if(m % 2 > 0) s = s + m;
else
{
d = m;
while(d % 2 == 0) d = d / 2;
s = s - d;
}
}
printf(" s(%d) = %ld\n", n, s);
return 0;
}
结果验证:
//求同吗小数和s(d, n)
int main()
{
int d, j, n;
double t, s;
printf(" 请输入整数d, n:");
scanf("%d, %d", &d, &n);
t = s = 0;
for (j = 1; j < n; j++)
{
t = t / 10 + (double)d / 10;
s += t;
}
printf(" S(%d, %d) = %.8f\n", d, n, s);
return 0;
}
结果验证:
//简化同码小数和s(d, n)
int main()
{
int d, n;
double s;
printf(" 请输入整数d, n");
scanf("%d,%d", &d, &n);
s = (n - 0.111111111) * d / 9;
printf(" s(%d, %d) = %.8f\n", d, n, s);
return 0;
}
结果验证:
//拓广同码小数和s(d, n)
int main()
{
int a, b, d, j, n;
double t, s;
printf(" 请输入整数d, n; ");
scanf("%d, %d", &d, &n);
a = d;
b = 1;
while (a > 0)
{
b = b * 10;
a = a / 10;
}
t = s = 0;
for (j = 1; j <= n; j++)
{
t = t / b + (double)d / b;
s += t;
}
printf(" s(%d, %d) = %.8f\n", d, n, s);
return 0;
}
结果:
边栏推荐
- C enum contains value - C enum contains value
- EGO Planner代码解析bspline_optimizer部分(2)
- Flutter网络和数据存储框架搭建 -b1
- A green plug-in that allows you to stay focused, live and work hard
- High concurrency Architecture - read write separation
- 【光学】基于matlab涡旋光产生【含Matlab源码 1927期】
- PyTorch中在反向传播前为什么要手动将梯度清零?
- Dynamic planning -- expansion topics
- Pecan — @expose()
- Driveseg: dynamic driving scene segmentation data set
猜你喜欢

2020 intermediate financial management (escort class)

Yolov3 network model building
![[leetcode] [SQL] notes](/img/8d/160a03b9176b8ccd8d52f59d4bb47f.png)
[leetcode] [SQL] notes

FBI警告:有人利用AI换脸冒充他人身份进行远程面试

01. Preparation for automated office (free guidance, only three steps)

The online customer service system developed by PHP is fully open source without encryption, and supports wechat customer service docking

Day_ 18 IO stream system

Octopus online ecological chain tour Atocha protocol received near grant worth $50000

Flutter network and data storage framework construction-b1

The installation path cannot be selected when installing MySQL 8.0.23
随机推荐
The earliest record
[mathematical modeling] ship three degree of freedom MMG model based on MATLAB [including Matlab source code 1925]
Record the errors reported when running fluent in the simulator
ActiveMQ的基础
Compared with 4G, what are the advantages of 5g to meet the technical requirements of industry 4.0
Free hand account sharing in September - [cream Nebula]
[proteus simulation] a simple encrypted electronic password lock designed with 24C04 and 1602LCD
__ Weak and__ The difference between blocks
QT -- qfileinfo file information reading
C enum contains value - C enum contains value
2020 intermediate financial management (escort class)
A green plug-in that allows you to stay focused, live and work hard
2022.2.14 Li Kou - daily question - single element in an ordered array
Failed to start component [StandardEngine[Catalina]. StandardHost[localhost]. StandardContext
SSM integration - joint debugging of front and rear protocols (list function, add function, add function status processing, modify function, delete function)
Next spread
Foundation of ActiveMQ
flask 生成swagger文档
How can I avoid "div/0!" Errors in Google Docs spreadsheet- How do I avoid the '#DIV/0!' error in Google docs spreadsheet?
Webrtc[41] - Analysis of the establishment process of webrtc transmission channel