当前位置:网站首页>【带你学c带你飞】3day第2章 用C语言编写程序(练习 2.3 计算分段函数)
【带你学c带你飞】3day第2章 用C语言编写程序(练习 2.3 计算分段函数)
2022-07-02 02:11:00 【尽力漂亮】
练习1
#include<stdio.h>
int main(){
int year,month,day;
scanf("%d-%d-%d",&month,&day,&year);
printf("%d-%02d-%02d",year,month,day);
return 0;
}
练习2
#include <stdio.h>
int main()
{
double x,y;
scanf("%lf",&x);
if(x<=15){y=4.0*x/3.0;}
else{y=2.5*x-10.5;}
printf("f(%.2f) = %.2f",x,y);
return 0;
}
3
#include <stdio.h>
#include<math.h>
int main()
{
//输入在一行中顺序给出两个正整数money、year和一个正实数rate,以空格分隔
int money,year;
double sum,rate;
scanf("%d %d %lf",&money,&year,&rate);
//pow(1+rate,year)意思是1+rate的year字幂
sum=money*pow(1+rate,year);
printf("sum = %0.2f",sum);
return 0;
}
标题
边栏推荐
- CSDN article underlined, font color changed, picture centered, 1 second to understand
- Pytest testing framework
- new和malloc的区别
- Architecture evolution from MVC to DDD
- 正则表达式学习笔记
- The smart Park "ZhongGuanCun No.1" subverts your understanding of the park
- Using mongodb in laravel
- [Video] visual interpretation of Markov chain principle and Mrs example of R language region conversion | data sharing
- From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years
- MySQL主从延迟问题怎么解决
猜你喜欢
Architecture evolution from MVC to DDD
leetcode2312. Selling wood blocks (difficult, weekly race)
Redis环境搭建和使用的方法
The concepts and differences between MySQL stored procedures and stored functions, as well as how to create them, the role of delimiter, the viewing, modification, deletion of stored procedures and fu
软件开发生命周期 --瀑布模型
[Video] Markov chain Monte Carlo method MCMC principle and R language implementation | data sharing
An analysis of circuit for quick understanding
How to use redis ordered collection
研发中台拆分过程的一些心得总结
From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years
随机推荐
How to build and use redis environment
2022 Q2 - 提昇技能的技巧總結
MySQL如何解决delete大量数据后空间不释放的问题
如何远程、在线调试app?
【视频】马尔可夫链原理可视化解释与R语言区制转换MRS实例|数据分享
MySQL constraints and multi table query example analysis
WebGPU(一):基本概念
Automatically browse pinduoduo products
np. Where and torch Where usage
leetcode2310. 个位数字为 K 的整数之和(中等,周赛)
Construction and maintenance of business websites [11]
牛客网——华为题库(51~60)
Golang lock
花一个星期时间呕心沥血整理出高频软件测试/自动化测试面试题和答案
【LeetCode 43】236. The nearest common ancestor of binary tree
[question] - why is optical flow not good for static scenes
* and & symbols in C language
剑指 Offer 47. 礼物的最大价值
Which is a good Bluetooth headset of about 300? 2022 high cost performance Bluetooth headset inventory
What is the MySQL column to row function