Advertisement
nguyenhappy92

Tính và xuất ra dạng Giờ:Phút:Giây

Oct 16th, 2015
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. // Nhap vao so giay tinh so gio:phut:giay
  2. // Khai bao ham thu vien neu co
  3. #include<stdio.h>
  4. #include<conio.h>
  5.  
  6. void main()
  7. {
  8. long t;
  9. scanf("%ld",&t);
  10. long h,m,s;
  11. // tinh gio
  12. h=(t/3600)%24;
  13. // tinh phut
  14. m=(t%3600)/60;
  15. // tinh giay
  16. s=(t%3600)%60;
  17. if(h==0||h<12)
  18. {
  19. printf("%d : %d : %d AM",h,m,s);
  20. }
  21. else
  22. {
  23. if((h-12)==12)
  24. {
  25. printf(" %d : %d : %d AM",h-24,m,s);
  26. }
  27. else
  28. {
  29. printf(" %d : %d : %d PM",h-12,m,s);
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement