Advertisement
titytus

InputTime

Oct 4th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. //-----Kiem tra gia tri hh:mm:ss-----
  2.  
  3. #include <stdio.h>
  4.  
  5. void nhap(int &h, int &m, int &s);
  6. bool kiemtra(int h, int m, int s);
  7. void xuat(bool a);
  8.  
  9. int main(){
  10.     int h,m,s;
  11.     nhap(h,m,s);
  12.     bool kq=kiemtra(h,m,s);
  13.     xuat(kq);
  14.     return 0;
  15. }
  16.  
  17. void nhap(int &h, int &m, int &s){
  18.     scanf("%d%d%d", &h, &m, &s);
  19. }
  20.  
  21. bool kiemtra(int h, int m, int s){
  22.     return ((h>=0)&&(h<24) && (m>=0)&&(m<60) && (s>=0)&&(s<60));
  23. }
  24.  
  25. void xuat(bool a){
  26.     if (a)
  27.         printf("Hop le");
  28.     else
  29.         printf("Khong hop le");
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement