c++ 时间相关的类型
2024-08-24 02:07:15
关于时间转换可以参考以下博客:
https://www.jianshu.com/p/80de04b41c31
https://www.cnblogs.com/qicosmos/p/3642712.html
https://blog.csdn.net/wizardtoh/article/details/81738682
https://blog.csdn.net/hou8389846/article/details/77962343
get_time put_time相关
https://blog.csdn.net/wangjieest/article/details/7761051
https://www.yiibai.com/cpp_standard_library/cpp_get_time.html
time_point 相关
https://www.xuebuyuan.com/716692.html?mobile=1
hdu 6491
时间间隔
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 153 Accepted Submission(s): 96
Problem Description
2019年1月1日,在云栖出现了可能是全世界最长的以秒为单位的倒计时装置:九亿多秒倒计时,直到2050年。
给出一个时间S,我们想知道S距离2050年1月1日0点0时0分多少秒。
因为答案可能很大,请输出答案模100的值。
Input
第一行一个正整数 T (1≤T≤100000)
表示数据组数。
对于每组数据,一行一个字符串表示时间。
时间格式为:YYYY-MM-DD HH:MM:SS,分别表示年、月、日、时,分、秒。
输入的时间保证都在2019年1月1日以后(包含当天)。
Output
对于每组数据输出一行一个整数表示答案。
Sample Input
1
2019-01-01 00:00:00
2019-01-01 00:00:00
Sample Output
0
#include<bits/stdc++.h>
using namespace std; int main()
{
string s;
stringstream ss;
s = "2050-01-01 00:00:00";
ss << s;
tm beg ;
ss >> get_time(&beg,"%Y-%m-%d");
ss >> get_time(&beg,"%H:%M:%S");
auto next_time = chrono::system_clock::from_time_t(time_t(mktime(&beg)));
int n;
cin>>n;
while(n--)
{
tm ed;
cin >> get_time(&ed,"%Y-%m-%d");
cin >> get_time(&ed,"%H:%M:%S");
auto from_time = chrono::system_clock::from_time_t(time_t(mktime(&ed)));
auto diff = next_time - from_time ;
cout<<abs(chrono::duration_cast<chrono::seconds>(diff).count())%<<endl;
}
return ;
}
最新文章
- 常用Linux命令收集
- 持续集成及部署利器:Go
- Java编程中“为了性能”需做的26件事
- .NET技术大系概览 (迄今为止最全的.NET技术栈)
- ctrip
- Python读取文本,输出指定中文(字符串)
- Docker 存储设置
- PHPCMS V9 点击量排行调用方法
- debian和ubuntu的sh dash bash
- LintCode ";The Smallest Difference";
- cocos2d-x创建工程批处理
- #include <;fstream>;
- 《linux内核完全剖析》笔记03-进程创建
- 巧用weui.gallery(),点击图片后预览图片
- Integer自动装箱拆箱bug,创建对象在-128到127
- 开源免费的C/C++网络库(c/c++ sockets library)补充
- 如何用vue实现树形菜单?
- ES6常用知识点小结
- TCP连接建立系列 — 客户端的端口选取和重用
- MySQL之内连接、左连接和右连接