作业:
1.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, const char *argv[])
{
printf("输入秒数:\n");
int t,s,m,h;
scanf("%d",&t);
h = t/3600;
m = (t/60)%60;
s = t%60;
printf(" = %d时%d分%d秒\n",h,m,s);
return 0;
}
2.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, const char *argv[])
{
printf("输入三个数:\n");
int a,b,c,x;
scanf("a=%d b=%d c=%d",&a,&b,&c);
x = a;
a = b;
b = c;
c = x;
printf("a=%d b=%d c=%d\n",a,b,c);
return 0;
}
3.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, const char *argv[])
{
int num,a,b,c;
printf("任意输入一个三位数:\n");
scanf("%d",&num);
a = num/100;
b = (num/10)%10;
c = num%10;
printf("a=%d\tb=%d\tc=%d\n",a,b,c);
printf("输出:%d\n",a+b+c);
return 0;
}
4.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, const char *argv[])
{
printf("输入一个实数:\n");
float x;
int m,n;
scanf("%f",&x);
m = (int)x+1;
n = (int)x;
printf("向上取整:%d\t向下取整:%d\n",m,n);
return 0;
}
最终结果:
补: