Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<iomanip>
- using namespace std;
- class timp
- {
- public:
- timp(int mm1, int ss1);
- void ConvToHour();
- void afisare();
- private:
- int hh,mm, ss;
- };
- timp::timp(int mm1, int ss1)
- { timp::hh = 0;
- timp::mm=mm1;
- timp::ss=ss1;
- }
- void timp::ConvToHour()
- {
- if(ss >= 60){
- mm = mm + ss/ 60;
- ss = ss % 60;
- }
- if(mm >= 60){
- hh = hh + mm/60;
- mm = mm % 60;
- }
- }
- void timp::afisare()
- { if(hh)
- cout<<"\nTimpul convertit este = "<<setw(2)<<setfill('0')<<hh<<" ore "<<setw(2)<<setfill('0')<<mm<<" minute "<<setw(2)<<setfill('0')<<ss<<" secunde" <<endl;
- else if(mm)
- cout<<"\nTimpul convertit este = "<< setw(2)<<setfill('0')<<mm<<" minute "<<setw(2)<<setfill('0')<<ss<<" secunde" <<endl;
- else if(ss)
- cout<<"\nTimpul convertit este = "<<setw(2)<<setfill('0')<<ss<<" secunde" <<endl;
- else
- cout <<"Nu exzista nici-o unitate de timp ";
- }
- int main()
- {
- timp t1(12500,15400);
- t1.ConvToHour();
- t1.afisare();
- timp t2(460,809);
- t2.ConvToHour();
- t2.afisare();
- }
Advertisement
Add Comment
Please, Sign In to add comment