试题 历届真题 时间显示【第十二届】【省赛】【B组】

注意事项有

  • 类型占用存储空间表数范围
    byte1字节-2^7 ~   2^7-1(-128~127)
    short2字节-2^15 ~   2^15-1(-32768~32767)
    int4字节-2^31 ~   2^31-1 (-2147483648~2147483647) 约21亿
    long4字节-2^31 ~   2^31-1
    long long8字节-2^63 ~   2^63-1
  • c++ 输出前补0,

    头文件:<iomanip>

    函数:setw(int n)

    函数:setfill(char c)(不调用该函数时默认用空格进行占位)

    cout<<setw(8)<<setfill('0')<<123<<endl;

    输出:00000123

  • #include<iostream>
    #include<iomanip>
    using namespace std;
    int main()
    {
    	long long time;
    	cin>>time;
    	time=time/1000;
    	int seconds=0;
    	int minute=0;
    	int hours=0;
    	seconds=time%60;
    	time=time/60;
    	minute=time%60;
    	time=time/60;
    	hours=time%24;
    	cout<<setw(2)<<setfill('0')<<hours<<":";
    	cout<<setw(2)<<setfill('0')<<minute<<":";
    	cout<<setw(2)<<setfill('0')<<seconds<<endl;
    	
    	
    	
    	
    	
    	return 0;
    } 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值