当前位置:网站首页>Time display of the 12th Blue Bridge Cup
Time display of the 12th Blue Bridge Cup
2022-06-13 05:00:00 【Clown clown clown】

Examination site : simulation .
For time , Common methods are modulo and division .
Common formula :
hour = time / 3600
min = time % 3600 / 60
sec = time % 3600 % 60
notes : Understanding of modular operation , Equivalent to filtering out unwanted seconds .
for instance min = time % 3600 / 60; It is equivalent to asking for the number of minutes , Filter out the hours that belong to ( subtract ), Then divide the remaining seconds by 60, Get the minutes .
Ideas :
This problem is a little distorted . Since there is no need to display year, month and day , Therefore, the number of seconds given should be filtered out first . namely time % (24 * 60 * 60)
And a little bit more , It's not the number of seconds , It's milliseconds , So first divide by 1000 Count seconds , Then carry out a series of operations .
Code :
#include <iostream>
using namespace std;
long long t;
int main()
{
cin >> t;
t /= 1000;// hold ms become s
t %= (24 * 60 * 60);// Filter out the seconds belonging to month, year and day
// Three formulas
int h = t / 3600;
int m = t % 3600 / 60;
int s = t % 3600 % 60;
printf("%02d:%02d:%02d", h, m, s);
}
notes : Don't cycle every second to find the final hour,minute,second. There will be a series of mistakes .
边栏推荐
- Ruoyi cloud startup tutorial (hand-held graphics)
- PostgreSQL Guide: Insider exploration (Chapter 7 heap tuples and index only scanning) - Notes
- RMQ、LCA
- Clause 33: decltype is used for auto & type formal parameters, with std:: forward
- Reductive elimination
- The differences between the four startup modes of activity and the applicable scenarios and the setting methods of the two startup modes
- Advanced C language - Section 1 - data storage
- Win8.1和Win10各自的优势
- CMB's written test -- data analysis
- Use service worker to preferentially request resources - continuous update
猜你喜欢

Design system based on MVC using javeswingjdbc

Conception d'un système basé sur MVC avec javaswing JDBC

Converting MySQL data to PostgreSQL with Navicat

Shell built-in string substitution

C language learning log 11.7

QT realizes message sending and file transmission between client and server

Draw a hammer
![[leetcode]- binary search](/img/7f/7d1f616c491c6fb0be93f591da6df1.png)
[leetcode]- binary search

RMQ、LCA

Section 8 - Practical commissioning techniques
随机推荐
[LeetCode]-二分查找
Brick story
Hidden implementation and decoupling, knowing Pimpl mode
语音信号分帧的理解
D 小红的构造题
Embedded hardware: electronic components (1) resistance capacitance inductance
shell变量学习笔记
QT using layout manager is invalid or abnormal
利用Javeswingjdbc基于mvc设计系统
Article 29: assuming that the mobile operation does not exist, is expensive, and is not used
Simple SR: best buddy Gans for highly detailed image super resolution
PostgreSQL Guide: inside exploration (Chapter 10 basic backup and point in time recovery) - Notes
详解OpenCV的函数cv::add(),并附各种情况的示例代码和运行结果
[leetcode]- binary search
Trust programming - linked lists: use struct to implement linked lists, use heap to merge K ascending linked lists, and customize display
C language learning log 1.2
Explain the opencv function cv:: add() in detail, and attach sample code and running results of various cases
Ruoyi cloud startup tutorial (hand-held graphics)
[JS solution] leedcode 117 Populate the next right node pointer II for each node
Use service worker to preferentially request resources - continuous update