当前位置:网站首页>Chapter 1: find the algebraic sum of odd factors, find the same decimal sum s (D, n), simplify the same code decimal sum s (D, n), expand the same code decimal sum s (D, n)
Chapter 1: find the algebraic sum of odd factors, find the same decimal sum s (D, n), simplify the same code decimal sum s (D, n), expand the same code decimal sum s (D, n)
2022-07-03 19:26:00 【Shares_ four】
// Find the algebraic sum of odd factors
int main()
{
int d, m, n;
long s;
printf(" please enter an integer 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;
}
The results verify that :
// Do you agree? Decimal sum s(d, n)
int main()
{
int d, j, n;
double t, s;
printf(" please enter an integer 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;
}
The results verify that :
// Simplified decimal sum of the same code s(d, n)
int main()
{
int d, n;
double s;
printf(" please enter an integer d, n");
scanf("%d,%d", &d, &n);
s = (n - 0.111111111) * d / 9;
printf(" s(%d, %d) = %.8f\n", d, n, s);
return 0;
}
The results verify that :
// Expand the decimal sum of the same code s(d, n)
int main()
{
int a, b, d, j, n;
double t, s;
printf(" please enter an integer 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;
}
result :
边栏推荐
- Summary of learning materials and notes of Zhang Fei's actual combat electronics 1-31
- Flask generates swagger documents
- Difference between surface go1 and surface GO2 (non professional comparison)
- Chapter 2: 4-digit Kaplan number, search even digit Kaplan number, search n-digit 2-segment sum square number, m-digit ingenious square number without 0, specify the number to form a 7-digit square nu
- Flume learning notes
- Verilog HDL continuous assignment statement, process assignment statement, process continuous assignment statement
- Using the visualization results, click to appear the corresponding sentence
- Chapter 1: extend the same code decimal sum s (D, n)
- We have built an intelligent retail settlement platform
- 【疾病识别】基于matlab GUI机器视觉肺癌检测系统【含Matlab源码 1922期】
猜你喜欢

第一章: 舍罕王失算

Ctrip will implement a 3+2 work system in March, with 3 days on duty and 2 days at home every week

Think of new ways

Recommend a GIF processing artifact less than 300K - gifsicle (free download)

PR 2021 quick start tutorial, material import and management

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

2022-06-25 网工进阶(十一)IS-IS-三大表(邻居表、路由表、链路状态数据库表)、LSP、CSNP、PSNP、LSP的同步过程

What does a really excellent CTO look like in my eyes

Chapter 1: simplify the same code decimal sum s (D, n)

The necessity of lean production and management in sheet metal industry
随机推荐
Flask generates swagger documents
Common text labels
Win10 share you don't have permission
【数学建模】基于matlab船舶三自由度MMG模型【含Matlab源码 1925期】
CMD implements the language conversion of locale non Unicode programs
第一章:三位阶乘和数,图形点扫描
04 -- QT OpenGL two sets of shaders draw two triangles
Summary of 90 day learning materials and notes of Zhang Fei's actual electronic hardware engineer
Day11 ---- 我的页面, 用户信息获取修改与频道接口
[proteus simulation] a simple encrypted electronic password lock designed with 24C04 and 1602LCD
Comments on flowable source code (37) asynchronous job processor
FBI warning: some people use AI to disguise themselves as others for remote interview
2022-06-30 網工進階(十四)路由策略-匹配工具【ACL、IP-Prefix List】、策略工具【Filter-Policy】
PR 2021 quick start tutorial, how to create new projects and basic settings of preferences?
[optics] dielectric constant calculation based on MATLAB [including Matlab source code 1926]
Summary of learning materials and notes of Zhang Fei's actual combat electronics 1-31
P3402 persistent and searchable
During MySQL installation, the download interface is empty, and the components to be downloaded are not displayed. MySQL installer 8.0.28.0 download interface is empty solution
Basic principle of LSM tree
Chapter 1: simplify the same code decimal sum s (D, n)