当前位置:网站首页>【C语言入门】ZZULIOJ 1011-1015
【C语言入门】ZZULIOJ 1011-1015
2022-07-24 06:35:00 【逝缘~】
ZZULIOJ 1011: 圆柱体表面积
题目描述
输入圆柱体的底面半径 r 和高 h,计算圆柱体的表面积并输出到屏幕上。要求定义圆周率为如下宏常量 #define PI 3.14159
输入
输入两个实数,为圆柱体的底面半径 r 和高 h。
输出
输出一个实数,即圆柱体的表面积,保留 2 位小数。
样例输入
42.1 71.6样例输出
30076.14#include <stdio.h>#include <stdlib.h>#define PI 3.14159int main(){ double r,h,s;scanf("%lf %lf",&r,&h);s=2*PI*r*h+2*PI*r*r;printf("%.2lf",s);return 0;}
ZZULIOJ 1012:求绝对值
题目描述
求实数的绝对值。
输入
输入一个实数。
输出
输出它的绝对值,结果保留两位小数
样例输入
-234.00样例输出
234.00#include <stdio.h>#include <stdlib.h>int main(){double m,n;scanf("%lf",&m);if(m>=0)n=m;elsen=m*(-1);printf("%.2f\n",n);return 0;}
ZZULIOJ 1013: 求两点间距离
题目描述
给定 A(x1, y1), B(x2, y2)两点坐标,计算它们间的距离。
输入
输入包含四个实数 x1, y1, x2, y2,分别用空格隔开,含义如描述。其中 0≤x1,x2,y1,y2≤100。
输出
输出占一行,包含一个实数 d,表示 A, B 两点间的距离。结果保留两位小数。
样例输入
1 1.5 2 2.5样例输出
1.41#include <stdio.h>#include <math.h>int main(){double x1,y1,x2,y2,d;scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));printf("%.2f\n",d);return 0;}
ZZULIOJ 1014:求三角形的面积
题目描述
给出三角形的三条边,求三角形的面积。
输入
输入三角形的三条边长(实数),数据之间用空格隔开。
输出
输出三角形的面积,结果保留 2 位小数。
样例输入
2.5 4 5样例输出
4.95提示
用海伦公式或其他方法均可。
#include <stdio.h>#include <stdlib.h>int main(){ double x,y,z,s;scanf("%lf %lf %lf",&x,&y,&z);s=sqrt(x*x*y*y/4-((x*x+y*y-z*z)*(x*x+y*y-z*z))/16);printf("%.2lf",s);return 0;}
ZZULIOJ 1015:计算时间间隔
题目描述
读入两个用“时:分:秒”表示的时间点,计算以秒为单位的时间间隔。
输入
输入有两行,每行是一个用“时:分:秒”表示的时间点。测试数据保证第二个时间点晚于第一个时间点。
输出
输出一个整数,表示时间间隔的秒数。
样例输入
08:00:0009:00:00
样例输出
3600提示
输入数据中带有普通字符,如冒号,scanf 函数的格式字符串中对应位置上也要有对应字符。
#include <stdio.h>#include <stdlib.h>#define PI 3.14159int main(){ int x,y,z,a,b,c,m;scanf("%d:%d:%d",&x,&y,&z);scanf("%d:%d:%d",&a,&b,&c);m=3600*a+60*b+c-3600*x-60*y-z;printf("%d",m);return 0;}
边栏推荐
- 找工作备忘
- 单点登录的三种实现方式
- 【LeetCode】444. 序列重建
- (note sorting is not completed) [graph theory: find the shortest path of single source]
- Processing tree structured data
- C language from entry to soil (III)
- Introduction to pyqt5 - student management system
- B. Also Try Minecraft
- Mongodb application scenario and model selection (massive data storage model selection)
- Practice of online problem feedback module (12): realize image deletion function
猜你喜欢
随机推荐
Penetration learning - SQL injection - shooting range - installation and bypass experiment of safety dog (it will be updated later)
【LeetCode】444. 序列重建
Do you really know the judgement sentence?
【LeetCode】11. 盛最多水的容器 - Go 语言题解
先爱自己,再爱别人。
17. 什么情况用ArrayList or LinkedList呢?
Who you are is up to you!
不去和谁比较,只需做好自己
5. Template cache. Drawing a square can only move within the triangle
sojson jsjiami.com. V6 crawler JS reverse
Requirements already satisfied: and read timed out. problem solving methods appear during the installation of snownlp package
2022-07-22 mysql/stonedb并行hashJoin内存占用分析
Wix path with spaces
[USB voltmeter and ammeter] Based on stm32f103c8t6 for Arduino
RIoTBoard开发板系列笔记(九)—— buildroot 移植MatchBox
MySql的DDL和DML和DQL的基本语法
【方向盘】超爱的IDEA提效神器Save Actions,卸载了
vs2019配置运行open3d例子
在线问题反馈模块实战(十二):实现图片删除功能
Never lose yourself!









