当前位置:网站首页>语法基础(变量、输入输出、表达式与顺序语句)
语法基础(变量、输入输出、表达式与顺序语句)
2022-08-05 02:34:00 【进击攻城狮】
作者:进击攻城狮
个人主页:欢迎访问我的主页
首发时间:2022年8月3日星期二
订阅专栏:刷题
个人信条:星光不问赶路人,岁月不负有心人。
如果文章有错误,欢迎在评论区指正。
支持我:点赞+收藏️+留言
文章目录
609.工资
请编写一个程序,可以读取一名员工的员工编号,本月工作总时长(小时)以及时薪,并输出他的工资条,工资条中包括员工编号和员工月收入。
输入格式
输入包含两个整数和一个浮点数,分别代表员工编号,工作时长以及时薪。
每个数占一行。
输出格式
输出共两行,第一行格式为 NUMBER = X
,其中 XX 为员工编号。
第二行格式为 SALARY = U$ Y
,其中 YY 为该员工月收入,保留两位小数。
数据范围
1≤员工编号≤1001≤员工编号≤100,
1≤总工作时长≤2001≤总工作时长≤200,
1≤时薪≤501≤时薪≤50
输入样例:
25
100
5.50
输出样例:
NUMBER = 25
SALARY = U$ 550.00
#include<iostream>
using namespace std;
int main(){
int id;
int time;
double price;
cin>>id>>time>>price;
printf("NUMBER = %d\nSALARY = U$ %.2f",id,time*price);
}
615.油耗
给定一个汽车行驶的总路程(kmkm)和消耗的油量(ll),请你求出汽车每消耗 11 升汽油可行驶多少公里路程。
输入格式
输入共两行,第一行包含整数 XX,表示行驶总路程。
第二行包含保留一位小数的浮点数 YY,表示消耗的油量。
输出格式
输出格式为 M km/l
,其中 MM 为计算结果,保留三位小数。
数据范围
1≤X,Y≤1091≤X,Y≤109
输入样例:
500
35.0
输出样例:
14.286 km/l
#include<iostream>
using namespace std;
int a;double b;
int main(){
cin>>a>>b;
printf("%.3lf km/l",a/b);
}
616.两点间的距离
给定两个点 P1P1 和 P2P2,其中 P1P1 的坐标为 (x1,y1)(x1,y1),P2P2 的坐标为 (x2,y2)(x2,y2),请你计算两点间的距离是多少。
distance=(x2−x1)2+(y2−y1)2−−−−−−−−−−−−−−−−−−√distance=(x2−x1)2+(y2−y1)2
输入格式
输入共两行,每行包含两个双精度浮点数 xi,yixi,yi,表示其中一个点的坐标。
输入数值均保留一位小数。
输出格式
输出你的结果,保留四位小数。
数据范围
−109≤xi,yi≤109−109≤xi,yi≤109
输入样例:
1.0 7.0
5.0 9.0
输出样例:
4.4721
#include<cstdio>
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
double a,b,c,d,e;
cin>>a>>b>>c>>d;
e=sqrt((c-a)*(c-a)+(d-b)*(d-b));
printf("%.4lf",e);
return 0;
}
653.钞票
在这个问题中,你需要读取一个整数值并将其分解为多张钞票的和,每种面值的钞票可以使用多张,并要求所用的钞票数量尽可能少。
请你输出读取值和钞票清单。
钞票的可能面值有 100,50,20,10,5,2,1100,50,20,10,5,2,1。
输入格式
输入一个整数 NN。
输出格式
参照输出样例,输出读取数值以及每种面值的钞票的需求数量。
数据范围
0<N<10000000<N<1000000
输入样例:
576
输出样例:
576
5 nota(s) de R$ 100,00
1 nota(s) de R$ 50,00
1 nota(s) de R$ 20,00
0 nota(s) de R$ 10,00
1 nota(s) de R$ 5,00
0 nota(s) de R$ 2,00
1 nota(s) de R$ 1,00
#include<iostream>
using namespace std;
int a;
int main(){
cin>>a;
printf("%d\n%d nota(s) de R$ 100,00\n",a,a/100);
printf("%d nota(s) de R$ 50,00\n",(a%100)/50);
printf("%d nota(s) de R$ 20,00\n",((a%100)%50)/20);
printf("%d nota(s) de R$ 10,00\n",(((a%100)%50)%20)/10);
printf("%d nota(s) de R$ 5,00\n",(((((a%100)%50)%20)%10)/5));
printf("%d nota(s) de R$ 2,00\n",((((((a%100)%50)%20)%10)%5)/2));
printf("%d nota(s) de R$ 1,00",(((((((a%100)%50)%20)%10)%5)%2)/1));
}
1 学如逆水行舟,不进则退
边栏推荐
- 剑指offer专项突击版第20天
- Amazon Cloud Technology joins hands with Thundersoft to build an AIoT platform for industry customers
- 2022-08-04: Input: deduplicated array arr, the numbers in it only contain 0~9.limit, a number.Return: The maximum number that can be spelled out with arr if the requirement is smaller than limit.from
- shell语句修改txt文件或者sh文件
- Access Characteristics of Constructor under Inheritance Relationship
- 01 [Foreword Basic Use Core Concepts]
- Programmer's Tanabata Romantic Moment
- 627. Change of gender
- 数据增强Mixup原理与代码解读
- Matlab map with color representation module value size arrow
猜你喜欢
SuperMap iDesktop.Net之布尔运算求交——修复含拓扑错误复杂模型
shell statement to modify txt file or sh file
[LeetCode Brush Questions] - Sum of Numbers topic (more topics to be added)
虚拟内存原理与技术
View handler 踩坑记录
Unleashing the engine of technological innovation, Intel joins hands with ecological partners to promote the vigorous development of smart retail
金仓数据库如何验证安装文件平台正确性
【genius_platform软件平台开发】第七十六讲:vs预处理器定义的牛逼写法!!!!(其他组牛逼conding人员告知这么配置来取消宏定义)
Flink 1.15.1 集群搭建(StandaloneSession)
蚁剑高级模块开发
随机推荐
Optimizing the feed flow encountered obstacles, who helped Baidu break the "memory wall"?
金仓数据库如何验证安装文件平台正确性
QStyle平台风格
nodeJs--封装路由
Matlab画图3
云原生(三十二) | Kubernetes篇之平台存储系统介绍
QT MV\MVC结构
[深入研究4G/5G/6G专题-51]: URLLC-16-《3GPP URLLC相关协议、规范、技术原理深度解读》-11-高可靠性技术-2-链路自适应增强(根据无线链路状态动态选择高可靠性MCS)
【C语言】详解栈和队列(定义、销毁、数据的操作)
1484. 按日期分组销售产品
sql语句多字段多个值如何进行排序
1873. The special bonus calculation
多线程(2)
shell语句修改txt文件或者sh文件
[ROS](10)ROS通信 —— 服务(Service)通信
js中try...catch和finally的用法
Semi-Decentralized Federated Learning for Cooperative D2D Local Model Aggregation
Using OpenVINO to implement the flying paddle version of the PGNet inference program
01 [Foreword Basic Use Core Concepts]
The 22-07-31 weeks summary