1 solutions
-
0
C :
#include<stdio.h> struct Time { int hour; int minute; int second; }; void update(struct Time *pt) { pt->second++; if(pt->second==60) { pt->second=0;pt->minute++; } if(pt->minute==60) { pt->minute=0; pt->minute++; } if(pt->hour==24) { pt->hour=0; } } void display(struct Time *pt) { printf("%d:%d:%d\n",pt->hour,pt->minute,pt->second); } void delay() { int t; for(t=0;t<100000000;t++); } int main() { int i; struct Time t1={0,0,0}; struct Time *p; p=&t1; for(i=0;i<5;i++) { update(p); display(p); delay(); } return 0; }
- 1
Information
- ID
- 17211
- Time
- 7000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By