📄 seconds.c
字号:
/* Illustrates the modulus operator. */
/* Inputs a number of seconds, and converts to hours, */
/* minutes, and seconds. */
#include <stdio.h>
/* Define constants */
#define SECS_PER_MIN 60
#define SECS_PER_HOUR 3600
unsigned seconds, minutes, hours, secs_left, mins_left;
int main( void )
{
/* Input the number of seconds */
printf("Enter number of seconds (< 65000): ");
scanf("%d", &seconds);
hours = seconds / SECS_PER_HOUR;
minutes = seconds / SECS_PER_MIN;
mins_left = minutes % SECS_PER_MIN;
secs_left = seconds % SECS_PER_MIN;
printf("%u seconds is equal to ", seconds);
printf("%u h, %u m, and %u s\n", hours, mins_left, secs_left);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -