|
发表于 2023-7-22 19:47:23
|
显示全部楼层
在指定的位置填写以下程序:
- for (j=0;j<i;j++)
- {
- if (a[j]>=10)
- printf("%d",a[j]);
- else
- printf("0%d",a[j]);
- if (j<i-1)
- printf(":");
- }
复制代码
完成后的完整程序如下所示:
- #include<stdio.h>
- #include<string.h>
- #include<math.h>
- #include<ctype.h>
- #include<stdlib.h>
- void handel(char a[], int n)
- {
- int i=0;
- for (;n>0;)
- {
- a[i++,i] = n % 60;
- n = n/60;
- }
- }
- int main()
- {
- int h, m, s, n, t, j;
- char a[10]={0};
- h=5,m=6,s=25;
- t = s + m*60 + h*3600;
- handel(a,t);
- n=0;
- // 输出结果
- for (j=0;j<i;j++)
- {
- if (a[j]>=10)
- printf("%d",a[j]);
- else
- printf("0%d",a[j]);
- if (j<i-1)
- printf(":");
- }
-
- return 0;
- }
复制代码
程序将根据给定的时、分、秒进行计算,并以 hh:mm:ss 的格式输出。例如,对于时、分、秒分别为 5、6、25,输出结果为:05:06:25。请注意,程序中的其他部分不应进行修改。
球一个最佳答案谢谢啦!这对我非常重要!   |
|