当前位置:网站首页>语法基础(变量、输入输出、表达式与顺序语句)
语法基础(变量、输入输出、表达式与顺序语句)
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 学如逆水行舟,不进则退
边栏推荐
猜你喜欢
![02 [Development Server Resource Module]](/img/60/f77ed0bb0e5654c9dcd70b73a5bee8.png)
02 [Development Server Resource Module]

The 20th day of the special assault version of the sword offer

RAID磁盘阵列

How to simply implement the quantization and compression of the model based on the OpenVINO POT tool

matlab绘制用颜色表示模值大小的箭头图

VSCode Change Default Terminal how to modify the Default Terminal VSCode

【OpenCV 图像处理2】:OpenCV 基础知识

Compressed storage of special matrices

js中try...catch和finally的用法

正则表达式,匹配中间的某一段字符串
随机推荐
使用SuperMap iDesktopX数据迁移工具迁移ArcGIS数据
力扣-二叉树的前序遍历、中序遍历、后序遍历
后期学习计划
leetcode-另一棵树的子树
VSCode Change Default Terminal how to modify the Default Terminal VSCode
627. 变更性别
lua learning
ARM Mailbox
Lexicon - the maximum depth of a binary tree
[C language] Detailed explanation of stacks and queues (define, destroy, and data operations)
1667. 修复表中的名字
HDU 1114: Piggy-Bank ← The Complete Knapsack Problem
Access Characteristics of Constructor under Inheritance Relationship
Pisanix v0.2.0 发布|新增动态读写分离支持
多线程(2)
行业案例|世界 500 强险企如何建设指标驱动的经营分析系统
QT语言文件制作
LeetCode uses the minimum cost to climb the stairs----dp problem
学习笔记-----左偏树
Pisanix v0.2.0 released | Added support for dynamic read-write separation