当前位置:网站首页>Syntax basics (variables, input and output, expressions and sequential statements)
Syntax basics (variables, input and output, expressions and sequential statements)
2022-08-05 02:44:00 【attack siege lion】
作者:进击攻城狮
个人主页:欢迎访问我的主页
首发时间:2022年8月4日星期四
订阅专栏:刷题
个人信条:星光不问赶路人,岁月不负有心人.
如果文章有错误,欢迎在评论区指正.
支持我:点赞+收藏️+留言
文章目录
654.时间转换
Read an integer value,It is the duration of an event in the factory(以秒为单位),Please convert it to hours:分钟:秒来表示.
输入格式
输入一个整数 NN.
输出格式
Output the converted time representation,格式为 hours:minutes:seconds
.
数据范围
1≤N≤10000001≤N≤1000000
输入样例:
556
输出样例:
0:9:16
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int x,y,z;
x=n/3600;
y=n%3600/60;
z=n%3600%60;
cout<<x<<':'<<y<<':'<<z<<endl;
return 0;
}
605. 简单乘积
读取两个整数值.
在此之后,计算它们的乘积并将结果存储在名为 PROD 的变量中.
输出结果如下例所示.
输入格式
共两行,每行包含一个整数.
输出格式
输出格式为 PROD = X
,其中 XX 为乘积结果.
数据范围
输入的两个整数的绝对值均不超过 1000010000.
输入样例:
3
9
输出样例:
PROD = 27
#include <stdio.h>
#include <string.h>
const int N = 10010;
int a, n;
int tr[N];
int lowbit(int x)
{
return x & -x;
}
void add(int x, int c)
{
for (int i = x; i <= n; i += lowbit(i))
tr[i] += c;
}
int sum(int x)
{
int res = 0;
for (int i = x; i; i -= lowbit(i))
res += tr[i];
return res;
}
int main()
{
scanf("%d %d", &a, &n);
printf("PROD = ");
if (n < 0) n = -n, a = -a;
for (int i = 1; i <= n; i ++ )
add(i, a);
printf("%d", sum(n));
return 0;
}
611.简单计算
Given the product numbers of your two products,Product quantity and product unit price.
Please calculate how much it will cost to buy both products.
输入格式
输入共两行.
Each line contains two integers and one floating point number,Indicates the product number of one of the products,Product quantity and product unit price.
输出格式
输出格式为 VALOR A PAGAR: R$ X
,其中 XX total product value,保留两位小数.
数据范围
1≤产品编号,产品数量≤100001≤产品编号,产品数量≤10000,
1.00≤产品单价≤10000.001.00≤产品单价≤10000.00
输入样例:
12 1 5.30
16 2 5.10
输出样例:
VALOR A PAGAR: R$ 15.50
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int a,b,c,d;
double e,f;
cin>>a>>b>>e>>c>>d>>f;
printf("VALOR A PAGAR: R$ %.2lf",b*e+d*f);
}
612.球的体积
给定你一个球体的半径 RR,请你计算球体的体积.
计算球体的公式为 V=(4/3)∗π∗R3V=(4/3)∗π∗R3.
ππ 取 3.141593.14159.
注意:有些语言中 (4/3)(4/3) 无法得到 1.3333…1.3333…,建议在公式中使用 (4/3.0)(4/3.0).
输入格式
输入一个整数 RR.
输出格式
输出格式为 VOLUME = X
,其中 XX 为球体的体积,结果保留三位小数.
数据范围
1≤R≤20001≤R≤2000
输入样例:
3
输出样例:
VOLUME = 113.097
#include<iostream>
using namespace std;
int main(){
double PI=3.14159;
int r;
cin>>r;
printf("VOLUME = %.3lf",4/3.0*PI*r*r*r);
return 0;
}
1 学如逆水行舟,不进则退
边栏推荐
猜你喜欢
Unleashing the engine of technological innovation, Intel joins hands with ecological partners to promote the vigorous development of smart retail
腾讯云【Hiflow】新时代自动化工具
RAID disk array
LeetCode uses the minimum cost to climb the stairs----dp problem
特殊矩阵的压缩存储
[ROS] (10) ROS Communication - Service Communication
How OpenGL works
【genius_platform软件平台开发】第七十六讲:vs预处理器定义的牛逼写法!!!!(其他组牛逼conding人员告知这么配置来取消宏定义)
The 2022 EdgeX China Challenge will be grandly opened on August 3
C language implements a simple number guessing game
随机推荐
tree table lookup
Multithreading (2)
HDU 1114: Piggy-Bank ← The Complete Knapsack Problem
语法基础(变量、输入输出、表达式与顺序语句)
Access Characteristics of Constructor under Inheritance Relationship
开源协议说明LGPL
Apache DolphinScheduler, a new generation of distributed workflow task scheduling platform in practice - Medium
[LeetCode Brush Questions] - Sum of Numbers topic (more topics to be added)
mysql tree structure query problem
LeetCode使用最小花费爬楼梯----dp问题
1484. Sell Products by Date
Common hardware delays
(十一)元类
Snapback - same tree
627. 变更性别
特殊矩阵的压缩存储
J9数字货币论:web3的创作者经济是什么?
数据增强Mixup原理与代码解读
2022了你还不会『低代码』?数据科学也能玩转Low-Code啦!
lua learning