D.8前导0的数字

xiaoxiao2021-02-28  70

任务及代码

/* *copyright(c)2017,学院 *All rights reserved. *文件名称: main.c *作 者: 杨隆胜 *完成日期: 2017年8月6日 *版 本 号: v1.0 * *问题描述:输入小时和分,以hh:mm形式输出,其中小时和分钟不足两位数时,用零前导 例,输入14 25,输出14:25,输入8 9,输出08:09 */ #include <stdio.h> int main() { int h,m; printf("Please input the hour(0<=hour<=23):\n"); scanf("%d",&h); printf("Please input the minute(0<=minute<=59):\n"); scanf("%d",&m); if(h<10) { printf("0"); } printf("%d:",h); if(m<10) { printf("0"); } printf("%d",m); return 0; }

运行结果

转载请注明原文地址: https://www.6miu.com/read-54935.html

最新回复(0)