当前位置:网站首页>第一章:喝汽水,阶梯电费计算,阶梯电费计算函数,个人所税,求解平方根不等式,简化求解平方根不等式,求解调和级数不等式,解不等式: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;
}
结果:
边栏推荐
- SQL injection for Web Security (1)
- I study database at station B (4): DQL
- flask 生成swagger文档
- Zhang Fei hardware 90 day learning notes - personal record on day 5. Please see my personal profile / homepage for the complete record
- Summary of learning materials and notes of Zhang Fei's actual combat electronics 1-31
- P1891 crazy LCM (Euler function)
- Yolov3 network model building
- [academic related] how to find the innovation of top papers? Chinese universities won the CVPR Best Student Thesis Award for the first time
- [optics] vortex generation based on MATLAB [including Matlab source code 1927]
- Using the visualization results, click to appear the corresponding sentence
猜你喜欢
Ego planner code parsing Bspline_ Optimizer section (2)
Does SQL always report foreign key errors when creating tables?
If the warehouse management communication is not in place, what problems will occur?
第二十章:y= sin(x)/x,漫步坐标系计算,y= sin(x)/x 带廓幅图形,奥运五环,小球滚动与弹跳,流水显示,矩形优化裁剪,r个皇后全控nxn棋盘
FBI警告:有人利用AI换脸冒充他人身份进行远程面试
Flume learning notes
Php based campus lost and found platform (automatic matching push)
利用可视化结果,点击出现对应的句子
Driveseg: dynamic driving scene segmentation data set
QT -- qfileinfo file information reading
随机推荐
[new year job hopping season] test the technical summary of interviewers' favorite questions (with video tutorials and interview questions)
2022.2.14 Li Kou - daily question - single element in an ordered array
DriveSeg:动态驾驶场景分割数据集
Basic principle of LSM tree
Php based campus lost and found platform (automatic matching push)
Differential constrained SPFA
Octopus online ecological chain tour Atocha protocol received near grant worth $50000
Zhang Fei hardware 90 day learning notes - personal record on day 6. Please see my personal profile / homepage for the complete record
Dynamic planning -- expansion topics
Find the median of two positive arrays
Luogu-p1107 [bjwc2008] Lei Tao's kitten
Summary of composition materials for 2020 high-frequency examination center of educational resources
Summary of learning materials and notes of Zhang Fei's actual combat electronics 1-31
Analysis of dart JSON encoder and decoder
The way to treat feelings
QT -- qfile file read / write operation
Flume learning notes
Verilog HDL continuous assignment statement, process assignment statement, process continuous assignment statement
Max of PHP FPM_ Some misunderstandings of children
Yolov3 network model building