当前位置:网站首页>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 :
边栏推荐
- The online customer service system developed by PHP is fully open source without encryption, and supports wechat customer service docking
- Find the median of two positive arrays
- Sentinel source code analysis part I sentinel overview
- Compared with 4G, what are the advantages of 5g to meet the technical requirements of industry 4.0
- Analysis of dart JSON encoder and decoder
- [leetcode] [SQL] notes
- Streaming media server (16) -- figure out the difference between live broadcast and on-demand
- 达梦数据库的物理备份和还原简解
- Recommend a GIF processing artifact less than 300K - gifsicle (free download)
- The earliest record
猜你喜欢

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

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

东数西算拉动千亿产业,敢啃“硬骨头”的存储厂商才更有机会

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

我们做了一个智能零售结算平台

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

Record: pymysql is used in pycharm to connect to the database

Common text labels

为什么要做特征的归一化/标准化?
![[academic related] how to find the innovation of top papers? Chinese universities won the CVPR Best Student Thesis Award for the first time](/img/06/5a37e2dca9711f8322b657581c3d75.png)
[academic related] how to find the innovation of top papers? Chinese universities won the CVPR Best Student Thesis Award for the first time
随机推荐
[academic related] how to find the innovation of top papers? Chinese universities won the CVPR Best Student Thesis Award for the first time
What is the content of game modeling
第一章:求所有阶乘和数,大奖赛现场统分程序设计,三位阶乘和数,图形点扫描,递归求n的阶乘n!,求n的阶乘n!,舍罕王失算
Flume learning notes
Zhang Fei hardware 90 day learning notes - personal record on day 5. Please see my personal profile / homepage for the complete record
Web Security (VIII) what is CSRF attack? Why can token prevent csdf attacks?
第二章:基于分解的求水仙花数,基于组合的求水仙花数, 兰德尔数,求[x,y]内的守形数,探求n位守形数,递推探索n位逐位整除数
Le changement est un thème éternel
交叉编译Opencv带Contrib
Read the paper glodyne global topology preserving dynamic network embedding
The installation path cannot be selected when installing MySQL 8.0.23
Smart wax therapy machine based on STM32 and smart cloud
我眼中真正优秀的CTO长啥样
[leetcode] [SQL] notes
Thesis study - 7 Very Deep Convolutional Networks for Large-Scale Image Recognition (3/3)
UE source code analysis: uccharactermovementcomponent - rootmotion
第二章:求a,b的最大公约与最小公倍数经典求解,求a,b的最大公约与最小公倍数常规求解,求n个正整数的的最大公约与最小公倍数
Random numbers in a long range, is that right- Random number in long range, is this the way?
Scrapy爬虫框架
Does SQL always report foreign key errors when creating tables?