当前位置:网站首页>第一章:喝汽水,阶梯电费计算,阶梯电费计算函数,个人所税,求解平方根不等式,简化求解平方根不等式,求解调和级数不等式,解不等式:d<1+1/2-1/3+1/4+1/5-1/6+..士1/n
第一章:喝汽水,阶梯电费计算,阶梯电费计算函数,个人所税,求解平方根不等式,简化求解平方根不等式,求解调和级数不等式,解不等式:d<1+1/2-1/3+1/4+1/5-1/6+..士1/n
2022-07-03 19:17:00 【股_四】
//喝汽水
int main()
{
long m, t, x, y;
printf("请输入人数:");
scanf("%d", &m);
x = m / 20;
t = m - 20 * x;
y = t / 3;
t = m - 20 * x - 3 * y;
printf("喝%ld瓶汽水,至少需要%.2f元", m, (13 * x + 2 * y) * 1.4 + t);
return 0;
}
验证结果:
//阶梯电费计算
int main()
{
double x,y;
printf(" 请输入月用电量(度):");
scanf ("%lf", &x);
if( x <= 240) //1/分3档计
y = x * 0.49;
else if (x <= 400)
y= 240 * 0.49 + (x - 240) *0.54;
else
y = 240 * 0.49 +(400-240) *0.54 + (x - 400) *0.79;
printf(" 应缴电费(元):%9.2f\n",y);
return 0;
}
结果:
//阶梯电费计算函数
double f (double x)
{
double y;
if (x <= 240)
y= x * 0.49;
else if (x <= 400)
y=f (240) + (x-240) *0.54; //调用自身函数
else y=f (400) + (x-400) *0.79;
return (y); //返回电费值了
}
int main()
{
double x;
printf(" 请输入月用电量: ");
scanf("%lf", &x);
printf("应交电费 %9.2f\n",f(x));
return 0;
}
结果:
//个人所得税
double s(double x)
{
double y, c, d;
d=0;
c=3500+d;
if (x<=c) y=0;
else if (x-c <= 1500)
y= (x-c) *0.03;
else if (x-c <= 4500)
y=s (c+1500) + (x-c-1500) *0.10;
else if (x-c <= 9000)
y=s(c+4500) + (x-c-4500) *0.20;
else if (x-c <= 35000)
y=s (c+9000) + (x-c-9000) *0.25;
else if (x-c <= 55000)
y=s (c+35000) + (x-c-35000) *0.30;
else if (x-c <= 80000)
y=s (c+55000) + (x-c-55000) *0.35;
else
y =s(c + 80000) + (x-c-80000) *0.45;
return (y) ;
}
int main()
{
double x;
printf(" 请输入月收入金额:");
scanf("%lf", &x);
printf(" 应交个人所税:%9.2f\n", s(x));
return 0;
}
结果:
//求解平方根不等式
int main()
{
long i, m; double n, s, s1;
printf(" 请输入正数n (n>3):");
scanf ("%lf", &n) ; //输入任意正数
m=0;
while (1)
{
m++;
s=0;
for (i=m; i<=2*m; i++)
s=s+sqrt (i) ; //对每一个川计算和 s
if (s >= n) break;
else s1=s; //为以下注明提供依据
}
printf(" 不等式的解为 m >= %ld\n",m);
printf("注:当m = %ld时, s = %.2f; 当 m = %ld时, s = %.2f\n", m-1, s1, m, s);
return 0;
}
结果:
//简化求解平方根不等式
int main()
{
long m;
double n, s, s1;
printf(" 请给入正数n (n > 3):");
scanf ("%lf", &n) ;//输入任意正数
m = 1;
s = 1.0+ sqrt (2);
do
{
m++;
s1 = s;
s = s - sqrt( m - 1) + sqrt(2 * m- 1) + sqrt (2*m);
}
while(s < n);
printf(" 不等式的解为 m >= %ld\n",m);
printf("注:当m = %ld时, s = %.2f; 当 m = %ld时, s = %.2f\n", m-1, s1, m, s);
return 0;
}
结果:
//求解调和级数不等式
int main()
{
long c, d, m;
double x, y, s;
printf(" 请输入正数 x,y (2<x<y): ");
scanf ("%lf,%lf", &x, &y);
m=0;
s=0;
while (s <= x) //循环求和探索m的下确界c
s = s + 1.0 / (++m);
c = m;
do
s = s + 1.0/ (++m) ;
while (s < y);//循环求和探索m的上确界d
d = m-1;
printf(" 满足不等式的解为:%1d ≤ m ≤ %1d \n", c, d);
return 0;
}
结果:
//解不等式:d<1+1/2-1/3+1/4+1/5-1/6+..士1/n
int main()
{
long n, k;
double d,s;
printf(" 请输入正数 d:");
scanf ("%lf", &d) ;
printf(" %lf <1+1/2-1/3+1/4+1/5-1/6+..+-1/n 的解:\n",d);
n=3;
s=3.0/2;
while (1)
{
s = s - 1.0 / n + 1.0 / (n+1) + 1.0 / (n+2);
if (s > d) break;
n = n + 3;
}
printf(" n = %ld \n", n + 2);
k = n + 2;
while(1)
{
if ((s = s - 1.0 / (++k)) > d) break;
if ((s = s + 1.0 / (++k)) > d) break;
s = s + 1.0 / (++k);
printf(" n = %ld \n", k) ; //离散解k
}
printf(" n >= %ld \n", k);
return 0;
}
结果:
//解不等式:d<1+1/2-1/3+1/4+1/5-1/6+..士1/n
int main()
{
long n, k;
double d,s;
printf(" 请输入正数 d:");
scanf ("%lf", &d) ;
printf(" %lf <1+1/2-1/3+1/4+1/5-1/6+..+-1/n 的解:\n",d);
n=1;
s=0;
while (1)
{
s = s + 1.0 / n + 1.0 / (n+1) - 1.0 / (n+2);
if (s > d) break;
n = n + 3;
}
printf(" n >= %ld \n", n + 1);
for(s = 0, k =1; k <= n; k++)
{
if(k % 3 > 0) s = s + 1.0 / k;
else s = s- 1.0/ k;
if(s > d) printf(" n = %ld \n", k);
}
return 0;
}
结果:
边栏推荐
- Flutter network and data storage framework construction-b1
- OSPF - detailed explanation of stub area and full stub area
- Floating source code comment (38) parallel job processor
- If the warehouse management communication is not in place, what problems will occur?
- Zhang Fei hardware 90 day learning notes - personal records on day 2, please see my personal profile / homepage for the complete
- Latex image rotates with title
- Differential constrained SPFA
- Nous avons fait une plateforme intelligente de règlement de détail
- Valentine's Day - make an exclusive digital collection for your lover
- Flask generates swagger documents
猜你喜欢
A green plug-in that allows you to stay focused, live and work hard
【疾病识别】基于matlab GUI机器视觉肺癌检测系统【含Matlab源码 1922期】
In addition to the prickles that pierce your skin, there are poems and distant places that originally haunt you in plain life
How to build an efficient information warehouse
SQL injection for Web Security (1)
Think of new ways
【光学】基于matlab介电常数计算【含Matlab源码 1926期】
Php based campus lost and found platform (automatic matching push)
【学术相关】顶级论文创新点怎么找?中国高校首次获CVPR最佳学生论文奖有感...
What does a really excellent CTO look like in my eyes
随机推荐
Driveseg: dynamic driving scene segmentation data set
math_泰勒公式
__ Weak and__ The difference between blocks
Pecan — @expose()
Verilog HDL continuous assignment statement, process assignment statement, process continuous assignment statement
Record: solve the problem that MySQL is not an internal or external command environment variable
[water quality prediction] water quality prediction based on MATLAB Fuzzy Neural Network [including Matlab source code 1923]
Ego planner code parsing Bspline_ Optimizer section (2)
What is the content of game modeling
我們做了一個智能零售結算平臺
[optics] dielectric constant calculation based on MATLAB [including Matlab source code 1926]
SQL injection for Web Security (1)
Simulation scheduling problem of SystemVerilog (1)
Record: install MySQL on ubuntu18.04
Sentinel source code analysis part II - sentinel dashboard console startup and configuration
【水质预测】基于matlab模糊神经网络水质预测【含Matlab源码 1923期】
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
P1891 crazy LCM (Euler function)
DriveSeg:动态驾驶场景分割数据集
Pytorch introduction to deep learning practice notes 13- advanced chapter of cyclic neural network - Classification