#include
void trans(int sec){
int hour,min;
hour=sec/3600; //计算时 3600进制
min=(sec%3600)/60; //计算分 60进制
sec=(sec%3600)%60; //计算秒 余下的全为秒数
printf("%d时:%d分:%d秒\n",hour,min,sec);
}
int main(){
int sec;
printf("请输入秒数:\n");
scanf("%d",&sec);
trans(sec);
return 0;
}
可以自己试试
#include
#include
void time_chang()
{
char time_in[10] = "";
int time_int = 0;
char hour,mind,sec;
gets(time_in);
time_int = atoi(time_in);
sec = time_int%100;
time_int/=100;
mind = time_int%100;
hour = time_int/100;
printf("%d:%d:%d\n",hour,mind,sec);
}
void main()
{
time_chang();
}