Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- struct Rellotge {
- int h; // hores (0<=h<24)
- int m; // minuts (0<=m<60)
- int s; // segons (0<=s<60)
- };
- Rellotge mitja_nit(){
- Rellotge r;
- r.h=0;
- r.m=0;
- r.s=0;
- return r;
- }
- void incrementa(Rellotge& r){
- ++r.s;
- if(r.s==60){
- r.s=0;
- ++r.m;
- if(r.m==60){
- r.m=0;
- ++r.h;
- if(r.h==24){
- r.h=0;
- }
- }
- }
- }
- void escriu(const Rellotge& r){
- cout<<setw(2)<<setfill('0')<<r.h<<':';
- cout<<setw(2)<<setfill('0')<<r.m<<':';
- cout<<setw(2)<<setfill('0')<<r.s<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement