当前位置:网站首页>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 :
边栏推荐
- Smart wax therapy machine based on STM32 and smart cloud
- 【光学】基于matlab涡旋光产生【含Matlab源码 1927期】
- Compared with 4G, what are the advantages of 5g to meet the technical requirements of industry 4.0
- Free hand account sharing in September - [cream Nebula]
- 【LeetCode】【SQL】刷题笔记
- I study database at station B (4): DQL
- Ctrip will implement a 3+2 work system in March, with 3 days on duty and 2 days at home every week
- 第一章:三位阶乘和数,图形点扫描
- Streaming media server (16) -- figure out the difference between live broadcast and on-demand
- 达梦数据库的物理备份和还原简解
猜你喜欢
Basic principle of LSM tree
第一章:三位阶乘和数,图形点扫描
Recommend a GIF processing artifact less than 300K - gifsicle (free download)
The earliest record
What is the content of game modeling
第一章:递归求n的阶乘n!
Why should the gradient be manually cleared before back propagation in pytorch?
Sentinel source code analysis part II - sentinel dashboard console startup and configuration
[disease identification] machine vision lung cancer detection system based on Matlab GUI [including Matlab source code 1922]
SSM整合-前后台协议联调(列表功能、添加功能、添加功能状态处理、修改功能、删除功能)
随机推荐
EGO Planner代码解析bspline_optimizer部分(3)
Which do MySQL and Oracle learn?
Web Security (VIII) what is CSRF attack? Why can token prevent csdf attacks?
Yolov3 network model building
Scrape crawler framework
[free sharing] kotalog diary2022 plan electronic manual ledger
The more you talk, the more your stupidity will be exposed.
第二章:求a,b的最大公约与最小公倍数经典求解,求a,b的最大公约与最小公倍数常规求解,求n个正整数的的最大公约与最小公倍数
The most valuable thing
Differential constrained SPFA
Analyse du Code du planificateur ego bspline Section Optimizer (1)
The necessity of lean production and management in sheet metal industry
FBI警告:有人利用AI换脸冒充他人身份进行远程面试
We have built an intelligent retail settlement platform
I study database at station B (4): DQL
The online customer service system developed by PHP is fully open source without encryption, and supports wechat customer service docking
第一章:求n的阶乘n!
BUUCTF
03 -- QT OpenGL EBO draw triangle
Latex image rotates with title