#include<stdio.h>
void main()
{
unsigned long t, r;
int d, h, m, s;
printf(“second=”);
scanf(“%d”, &t);
d=t/(24*3600);
r=t%(24*3600);
h=r/3600;
m=(r%3600)/60;
s=(r%3600)%60;
printf(“have passed days is %d, current time is %02d:%02d:%02d\n”, d, h, m, s):
}
习题5参考答案
编程题
1、编一程序判断输入整数的正负性和奇偶性。
#include<stdio.h>
void main()
{
int a;
scanf(“%d”, &a);
if (a>=0)
printf(“the number %d is positive number\n”, a);
else
printf(“the number %d is negative number\n”, a);