当前位置:网站首页>Blue Bridge Cup basic-14 VIP question time conversion
Blue Bridge Cup basic-14 VIP question time conversion
2022-06-12 19:29:00 【Hua Weiyun】
test questions Based on practice Time shift
import java.util.Scanner;
public class Main {
/**
* Given a time in seconds t, Asked to use “<H>:<M>:<S>” To represent this time .
* <H> Time ,<M> Represents minutes , and <S> For seconds , They are all integers and have no leading “0”.
* for example , if t=0, The output should be “0:0:0”; if t=3661, The output “1:1:1”.
*/
public static void main(String[] args) {
// receive data
Scanner scanner = new Scanner(System.in);
// Acceptance time seconds
int a = scanner.nextInt();
// Judge a Is it 1 Hour up
if (a - 3600 >= 0) {
// H Hours a/3600
int H = a / 3600;
// F minute Equal to the entered a- Hours = minute + second
int F = (a - H*3600) / 60;
// S second Equal to the entered a- Hours divided by 60 Remainder
int S = (a - H*3600) % 60;
System.out.println(H + ":" + F + ":" + S);
} else { // Not more than one hour , Find out directly
int H = 0;
int F = a / 60;
int S = a % 60;
System.out.println(H + ":" + F + ":" + S);
}
}
}
The demonstration effect is as follows --

I hope that's helpful !!
Thank you. !
边栏推荐
- 基于微信电子书阅读小程序毕业设计毕设作品(3)后台功能
- VC hacon joint programming genimage3extern writeimage
- leetcodeSQL:602. Friend application II: who has the most friends
- In 2021, the global fire pump drive power revenue is about $381million, and it is expected to reach $489.3 million in 2028
- 超级重磅!Apache Hudi多模索引对查询优化高达30倍
- Add, delete, modify and query mysql, common MySQL commands
- 3D object detection
- [today in history] June 12: the United States entered the era of digital television; Mozilla's original developer was born; 3com merges with American Robotics
- 美团获得小样本学习榜单FewCLUE第一!Prompt Learning+自训练实战
- The component style set by uniapp takes effect in H5 and app, but does not take effect in wechat applet. The problem is solved
猜你喜欢

RT-Thread 模拟器 simulator 搭建 LVGL 的开发调试环境

负数取余问题

【图像去噪】基于各向异性滤波实现图像去噪附matlab代码

基于微信电子书阅读小程序毕业设计毕设作品(4)开题报告

RT thread simulator builds lvgl development and debugging environment
![leetcode:5259. Calculate the total tax payable [simple simulation + see which range]](/img/f4/e6329c297dbe668e70f5e37bfc2852.png)
leetcode:5259. Calculate the total tax payable [simple simulation + see which range]

The Bean Validation API is on the classpath but no implementation could be found

RHCA回忆录---CL280介绍

5g R17 standard is frozen. What does it say?
![[observation] Huawei's next generation data center](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[observation] Huawei's next generation data center "adds momentum" to Guangxi's low-carbon and high-quality development
随机推荐
美团获得小样本学习榜单FewCLUE第一!Prompt Learning+自训练实战
Mysql database (28): Variables
[matrix theory & graph theory] final exam review mind map
5g R17 standard is frozen. What does it say?
Report on market demand trends and future strategic planning recommendations of the global and Chinese smart financial solutions industry 2022-2028
3D object detection
Leetcodesql: count the number of students in each major
Istio 1.14 发布
Shell 数组和函数
Méthode de sauvegarde programmée basée sur la base de données distribuée elle - même
基于微信电子书阅读小程序毕业设计毕设作品(7)中期检查报告
Software usage of Tencent cloud TDP virt viewer win client
[observation] Huawei's next generation data center "adds momentum" to Guangxi's low-carbon and high-quality development
easycode一键生成插件自定义模板
VC Hacon Joint Programming genimage3extern writeimage
BannerViewPager
Cookie & Session & kaptcha驗證碼
3GPP RAN第一次F2F会议,都干了些啥?
Start with no place to live
The 14th five year development plan and investment prospect analysis report of China's oil and gas pipeline engineering construction 2022-2027