编写程序,输入某一时刻的时间,加一秒后输出新的时间,时间以时、分、秒表示(利用结构类型)...

 1 #include <stdio.h>
 2 
 3 struct  myTime
 4 {
 5     int h;
 6     int m;
 7     int s;
 8 };
 9 
10 int main()
11 {
12     struct myTime T;
13     int h,m,s;
14     printf("输入小时:");
15     scanf("%d",&h);
16     printf("输入分钟:");
17     scanf("%d",&m);
18     printf("输入秒:");
19     scanf("%d",&s);
20     T.h=h;
21     T.m=m;
22     T.s=s;
23     if (s==59)
24     {
25         T.s=0;
26         T.m++;
27         if (T.m==60)
28         {
29             T.m=0;
30             T.h++;
31             if (T.h==24)
32             {
33                 T.h=0;
34             }
35         }
36     } 
37     else
38     {
39         T.s++;
40     }
41     printf("时间%d:%d:%d加1秒后等于%d:%d:%d\n",h,m,s,T.h,T.m,T.s);
42     return 0;
43 }

 

转载于:https://www.cnblogs.com/bonke/archive/2013/06/16/3138760.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值