当前位置:网站首页>第一章:求奇因数代数和,求同吗小数和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;
}
结果:
边栏推荐
- Scrapy爬虫框架
- FBI warning: some people use AI to disguise themselves as others for remote interview
- [free sharing] kotalog diary2022 plan electronic manual ledger
- Scrape crawler framework
- 我眼中真正优秀的CTO长啥样
- Yolov3 network model building
- Sentinel source code analysis part I sentinel overview
- cipher
- Ego planner code parsing Bspline_ Optimizer section (2)
- I didn't cancel
猜你喜欢
The necessity of lean production and management in sheet metal industry
第一章:三位阶乘和数,图形点扫描
第一章:求n的阶乘n!
Nous avons fait une plateforme intelligente de règlement de détail
Record: writing MySQL commands
I study database at station B (4): DQL
ActiveMQ的基础
我眼中真正优秀的CTO长啥样
Merge K ascending linked lists
SQL injection for Web Security (1)
随机推荐
第二章:基于分解的求水仙花数,基于组合的求水仙花数, 兰德尔数,求[x,y]内的守形数,探求n位守形数,递推探索n位逐位整除数
Integrated easy to pay secondary domain name distribution system
FBI warning: some people use AI to disguise themselves as others for remote interview
Foundation of ActiveMQ
Counting from the East and counting from the West will stimulate 100 billion industries. Only storage manufacturers who dare to bite the "hard bone" will have more opportunities
Work Measurement - 1
Help change the socket position of PCB part
We have built an intelligent retail settlement platform
Analyse du Code du planificateur ego bspline Section Optimizer (1)
Sustainable service business models
Why should the gradient be manually cleared before back propagation in pytorch?
cipher
SSM整合-前后台协议联调(列表功能、添加功能、添加功能状态处理、修改功能、删除功能)
Record: install MySQL on ubuntu18.04
If the warehouse management communication is not in place, what problems will occur?
OSPF - detailed explanation of stub area and full stub area
235. Ancêtre public le plus proche de l'arbre de recherche binaire [modèle LCA + même chemin de recherche]
High concurrency Architecture - separate databases and tables
论文阅读 GloDyNE Global Topology Preserving Dynamic Network Embedding
Zhang Fei hardware 90 day learning notes - personal records on day 2, please see my personal profile / homepage for the complete