Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Time {
- // your code goes here
- // Cac bien thanh vien
- int h ;
- int m ;
- int s ;
- // your code goes here
- // Hai ham khoi tao
- Time (){
- h=0 ;
- m=0 ;
- s =0 ;
- }
- Time ( int _h , int _m , int _s ){
- h=_h ;
- m=_m ;
- s=_s;
- }
- int second() {
- // your code goes here
- int res = s + m * 60 + h * 60 * 60 ;
- return res ;
- }
- void print() {
- // your code goes here
- string hourr = string ( 2- to_string(h).size(),'0' ) + to_string(h);
- string secc = string ( 2- to_string(s).size(),'0' ) + to_string(s);
- string minn = string ( 2- to_string(m).size(),'0' ) + to_string(m);
- string res = hourr + ":" +minn + ":" + secc ;
- cout << res << endl;
- }
- };
- Time normalize(int h, int m, int s) {
- // your code goes here
- Time res ;
- int realSec = s , realMin =m , realHour =h ;
- if ( s>=60 ){
- realSec = s% 60 ;
- realMin = m + s/60 ;
- }
- if ( realMin >= 60 ){
- realHour = h + realMin/60;
- realMin = realMin % 60;
- }
- if ( realHour == 24 ){
- realHour =0 ;
- }
- else if ( realHour > 24 ){
- realHour = realHour - 24 ;
- }
- res.h = realHour ;
- res.m = realMin ;
- res.s = realSec;
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment