fjnu 1269 Fuzzy Time

本文介绍了一个将精确秒数转换为更易读的模糊时间格式的程序。该程序根据不同的时间范围,采用天数、小时数、分钟数或秒数来表示时间,并遵循特定的输出规则。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Description

Kyle is downloading a moe. concert using BitTorrent. He notices that the time left is given as "2 hours 15 minutes." Later it becomes "0 minutes 37 seconds" and then finally finishes. Kyle thinks about it and decides that the program could easily say "8,101 seconds" to be precise, but that this isn't very useful. He wants you to write a program that, given a time in seconds, prints out a less precise, but more useful ("fuzzy") version.
The rules for fuzziness that Kyle wants implemented are:

.Any time longer than or equal to 48 hours, should be given in terms of the number of days.
.Between 1 hour(inclusive) and 48 hours, the program should display the number of hours and number of minutes left.
.Between 5 minutes and 59 minutes, 59 seconds, inclusive, the program should only display the number of minutes left.
.Less than 5 minutes should be displayed as the number of minutes and number of seconds left.

No rounding is to be done. Anything left over is simply dropped, so 365 and 419 would both be displayed as "6 minutes". Kyle would also like you to use proper plural forms.

While you're working on that, Kyle is going to go listen to the concert, which apparently has an amazing version of "Timmy Tucker" on it.

Input

Each line of input gives one time, in seconds, that you are to convert. Input is terminated by end of file.

Output

For each input, print out the fuzzy time version according to the rules Kyle gave you above.

Sample Input

0
65
365
419
7270
172800
300000

 

Sample Output

0 minutes 0 seconds
1 minute 5 seconds
6 minutes
6 minutes
2 hours 1 minute
2 days
3 days
KEY:这题不难,注意输出,当是1的时候没有单位s,0居然有啊……-_-我这几年的英语白读了;
 
Source:#include<iostream>
using namespace std;

struct
 node
{
    
int
 day;
    
int
 hour;
    
int
 minute;
    
int
 second;
}
;

node a;

void time(int
 t)
{
    a.day
=t/86400
;
    t
=t%86400
;
    a.hour
=t/3600
;
    t
=t%3600
;
    a.minute
=t/60
;
    t
=t%60
;
    a.second
=
t;
    
if(a.day==1

    
{
        a.hour
+=24
;
        a.day
=0
;
    }

}


void output(int t)
{
    
if(t>=172800) cout<<a.day<<" days"<<
endl;
    
if(t>=3600&&t<172800
)
    
{
        
if(a.hour>=0) cout<<a.hour<<" hour"
;
        
if(a.hour!=1) cout<<"s"
;
        cout
<<" "
;
        
if(a.minute>=0) cout<<a.minute<<" minute"
;
        
if(a.minute!=1) cout<<"s"
;
        cout
<<
endl;
    }

    
if(t>=300&&t<=3599) cout<<a.minute<<" minutes"<<endl;
    
if(t<300
)
    
{
        
if(a.minute>=0) cout<<a.minute<<" minute"
;
        
if(a.minute!=1) cout<<"s"
;
        cout
<<" "
;
        
if(a.second>=0) cout<<a.second<<" second"
;
        
if(a.second!=1) cout<<"s"
;
        cout
<<
endl;
    }

}


int main()
{
//    freopen("fjnu_1269.in","r",stdin);

    int t;
    
while(cin>>
t)
    
{
        time(t);
        output(t);
    }

    
return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值