004
10.11.2004, 18:46 Uhr
derphilipder
|
Ich hab da mal was gebastelt, was sone Art Eieruhr sein sollte:
C++: |
#include <iostream> #include <ctime> #include <conio.h> #include <iomanip> #include <string> #include <sstream> #include <windows.h> using namespace std;
#define CLS system("cls")
inline int digits(int x) { stringstream dig; string _dig;
dig << x;
dig >> _dig; return _dig.length(); }
int main(int argc, char* argv[]) {
//string s(40, '\n'); char c; //cout <<s; do{CLS; long sek = 0, init; int n, h, m, s; cout << "Countdownzeit: \n\n" << "Stunden : "; cin >> h; cout << "Minuten : "; cin >> m; cout << "Sekunden: "; cin >> s;
n = 3600*h + 60*m + s;
cout <<"\n\nCountdown: " << setw(digits(n/3600)+9) << n ;
time(&init);
string space(digits(n/3600)+9, '\b');
while(true) { Sleep(1000); long lok; time(&lok);
if(lok > sek) { sek=lok; cout << space << setfill('0') << setw(digits(n/3600)) << (n - (sek - init))/3600 <<"h " << setw(2) << ((n - (sek - init))%3600)/60 << "m " << setw(2) << (n - (sek - init))%60 << 's' ; }
if(sek >= init + n) break;
if(kbhit()) if((c=getch()) == 27) break; } if(c != 27) { cout << "\n\n\nDas Druecken einer Taste beendet diesen unangenehmen Ton!"; for(int i = 0; i < 1000; i++) { cout<<"\a"; if(kbhit()) break; } }
for(;;){getch(); if(!kbhit())break;}
cout << "\n\nEnde mit Escape, weiter mit bel. Taste\n\n"; c = getch();
}while(c!=27); return 0; }
|
Vielleicht könnt Ihr damit ja was anfangen... -- Konfuzius says: "A man who goes to bed with an itchy asshole is a man who wakes up with stinky finger!" |