当前位置:网站首页>Chapter 1: drinking soft drinks, step tariff calculation, step tariff calculation function, personal income tax, solving square root inequality, simplifying solving square root inequality, solving dem
Chapter 1: drinking soft drinks, step tariff calculation, step tariff calculation function, personal income tax, solving square root inequality, simplifying solving square root inequality, solving dem
2022-07-03 19:20:00 【Shares_ four】
// Drink soda
int main()
{
long m, t, x, y;
printf(" Please enter the number of people :");
scanf("%d", &m);
x = m / 20;
t = m - 20 * x;
y = t / 3;
t = m - 20 * x - 3 * y;
printf(" drink %ld Bottle of soda , Need at least %.2f element ", m, (13 * x + 2 * y) * 1.4 + t);
return 0;
}
The verification results :
// Step tariff calculation
int main()
{
double x,y;
printf(" Please input the monthly electricity consumption ( degree ):");
scanf ("%lf", &x);
if( x <= 240) //1/ branch 3 Gear meter
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(" Electricity fee payable ( element ):%9.2f\n",y);
return 0;
}
result :
// Step tariff calculation function
double f (double x)
{
double y;
if (x <= 240)
y= x * 0.49;
else if (x <= 400)
y=f (240) + (x-240) *0.54; // Call its own function
else y=f (400) + (x-400) *0.79;
return (y); // Return the electricity price
}
int main()
{
double x;
printf(" Please input the monthly electricity consumption : ");
scanf("%lf", &x);
printf(" Electricity fee payable %9.2f\n",f(x));
return 0;
}
result :
// Individual income tax
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(" Please enter the monthly income amount :");
scanf("%lf", &x);
printf(" Personal income tax payable :%9.2f\n", s(x));
return 0;
}
result :
// Solve the square root inequality
int main()
{
long i, m; double n, s, s1;
printf(" Please enter a positive number n (n>3):");
scanf ("%lf", &n) ; // Enter any positive number
m=0;
while (1)
{
m++;
s=0;
for (i=m; i<=2*m; i++)
s=s+sqrt (i) ; // Calculate and s
if (s >= n) break;
else s1=s; // Provide basis for the following notes
}
printf(" The solution of the inequality is m >= %ld\n",m);
printf(" notes : When m = %ld when , s = %.2f; When m = %ld when , s = %.2f\n", m-1, s1, m, s);
return 0;
}
result :
// Simplify solving square root inequality
int main()
{
long m;
double n, s, s1;
printf(" Please add a positive number n (n > 3):");
scanf ("%lf", &n) ;// Enter any positive number
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(" The solution of the inequality is m >= %ld\n",m);
printf(" notes : When m = %ld when , s = %.2f; When m = %ld when , s = %.2f\n", m-1, s1, m, s);
return 0;
}
result :
// Find demodulation and series inequality
int main()
{
long c, d, m;
double x, y, s;
printf(" Please enter a positive number x,y (2<x<y): ");
scanf ("%lf,%lf", &x, &y);
m=0;
s=0;
while (s <= x) // Cyclic summation exploration m The lower bound of c
s = s + 1.0 / (++m);
c = m;
do
s = s + 1.0/ (++m) ;
while (s < y);// Cyclic summation exploration m The upper bound of d
d = m-1;
printf(" The solution satisfying the inequality is :%1d ≤ m ≤ %1d \n", c, d);
return 0;
}
result :
// Solving inequalities :d<1+1/2-1/3+1/4+1/5-1/6+.. Scholar 1/n
int main()
{
long n, k;
double d,s;
printf(" Please enter a positive number d:");
scanf ("%lf", &d) ;
printf(" %lf <1+1/2-1/3+1/4+1/5-1/6+..+-1/n Solution :\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) ; // Discrete solution k
}
printf(" n >= %ld \n", k);
return 0;
}
result :
// Solving inequalities :d<1+1/2-1/3+1/4+1/5-1/6+.. Scholar 1/n
int main()
{
long n, k;
double d,s;
printf(" Please enter a positive number d:");
scanf ("%lf", &d) ;
printf(" %lf <1+1/2-1/3+1/4+1/5-1/6+..+-1/n Solution :\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;
}
result :
边栏推荐
- Merge K ascending linked lists
- Succession of flutter
- Flutter网络和数据存储框架搭建 -b1
- The most valuable thing
- Sqlalchemy - subquery in a where clause - Sqlalchemy - subquery in a where clause
- Dynamic planning -- expansion topics
- 01 - QT OpenGL display OpenGL window
- PyTorch中在反向传播前为什么要手动将梯度清零?
- 论文阅读 GloDyNE Global Topology Preserving Dynamic Network Embedding
- [proteus simulation] a simple encrypted electronic password lock designed with 24C04 and 1602LCD
猜你喜欢

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

SSM integration - joint debugging of front and rear protocols (list function, add function, add function status processing, modify function, delete function)

BUUCTF

第二章:求a,b的最大公约与最小公倍数经典求解,求a,b的最大公约与最小公倍数常规求解,求n个正整数的的最大公约与最小公倍数

DriveSeg:动态驾驶场景分割数据集

Recommend a GIF processing artifact less than 300K - gifsicle (free download)
![[disease identification] machine vision lung cancer detection system based on Matlab GUI [including Matlab source code 1922]](/img/fc/00835b95537cf889588502a3d13bc9.png)
[disease identification] machine vision lung cancer detection system based on Matlab GUI [including Matlab source code 1922]

Free sharing | linefriends hand account inner page | horizontal grid | not for sale

Thesis study - 7 Very Deep Convolutional Networks for Large-Scale Image Recognition (3/3)

Integrated easy to pay secondary domain name distribution system
随机推荐
Flutter网络和数据存储框架搭建 -b1
If the warehouse management communication is not in place, what problems will occur?
Basic principle of LSM tree
Verilog HDL continuous assignment statement, process assignment statement, process continuous assignment statement
“google is not defined” when using Google Maps V3 in Firefox remotely
FBI警告:有人利用AI换脸冒充他人身份进行远程面试
Zhang Fei hardware 90 day learning notes - personal records on day 2, please see my personal profile / homepage for the complete
利用可视化结果,点击出现对应的句子
Dart JSON编码器和解码器剖析
Think of new ways
How to build an efficient information warehouse
我眼中真正优秀的CTO长啥样
Flume learning notes
2020 intermediate financial management (escort class)
Flutter network and data storage framework construction-b1
第二章:求a,b的最大公约与最小公倍数经典求解,求a,b的最大公约与最小公倍数常规求解,求n个正整数的的最大公约与最小公倍数
High concurrency Architecture - separate databases and tables
[mathematical modeling] ship three degree of freedom MMG model based on MATLAB [including Matlab source code 1925]
05 -- QT OpenGL draw cube uniform
第二章:求长方体数组,指定区间内的完全数,改进指定区间内的完全数