#include <stdio.h>
#include <string.h>
char *seconds_to(int seconds)
{
static char time[100];
sprintf(time, "%d小时%d分钟%d秒", seconds / 3600, seconds % 3600 / 60, seconds % 60);
return time;
}
int main()
{
int seconds;
printf("请输入时间(秒):\n");
scanf("%d", &seconds);
printf("%d秒合计%s!\n", seconds, seconds_to(seconds));
}
写一个函数将以秒计数的时间转换为以时、分、秒计数的时间。 函数原型为:char *seconds_to(int seconds)。 编写main调用测试它。 **输入格式要求:"%d" 提示信息:"请输入时间(秒):\n" **输出格式要求:"%d秒合计%s!\n" "%d小时%d分钟%d秒"