Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <iomanip>
- using namespace std;
- //zmienne
- short g,m,s;
- int main()
- {
- //ustawienie godziny
- cout<<"Podaj godzine {GG MM SS}, lub wpisz dowolny znak aby zaczac odliczac od zera!";
- cin>> g;
- cin>> m;
- cin>> s;
- //sprawdza czy godzina została podana prawidłowo
- if (g<0 || g>23)
- {
- cout<<"Godzina zostala podana w zly sposob."<<endl;
- return main();
- }
- if (m<0 || m>59 )
- {
- cout<<"Godzina zostala podana w zly sposob."<<endl;
- return main();
- }
- if (s<0 || s>59)
- {
- cout<<"Godzina zostala podana w zly sposob."<<endl;
- return main();
- }
- //zegar
- while(true)
- {
- s++;
- system("cls");
- if(s==60)
- {
- m++;
- s=0;
- }
- if (m==60)
- {
- g++;
- m=0;
- }
- if (g==24)
- {
- s=0;
- m=0;
- g=0;
- }
- cout << setfill('0') << setw(2) << g<<":"<< setfill('0') << setw(2) << m <<":"<< setfill('0') << setw(2) << s << endl;
- Sleep(1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement