程序员专属倒计时:
#include<bits/stdc++.h>
#include<windows.h>
#include<unistd.h>
#define R SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
#define Y SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED | FOREGROUND_GREEN);
#define G SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN);
#define C SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_GREEN | FOREGROUND_BLUE);
#define B SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_BLUE);
#define P SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED | FOREGROUND_BLUE);
#define I SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY);
#define W SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
using namespace std;
int d,h,m,s,clr;
void pt(int p){
if(p<10)
cout<<"0";
cout<<p;
}
void bp(int m){
Beep(m,250);
Sleep(200);
}
int main(){
do{
system("cls");
cout<<"Day(s):";
cin>>d;
cout<<"Hour(s):";
cin>>h;
cout<<"Minute(s):";
cin>>m;
cout<<"Second(s):";
cin>>s;
}while(h>23 || m>59 || s>59);
while(d || h || m || s){
system("cls");
switch(clr){
case 0:P break;
case 1:B break;
case 2:C break;
case 3:G break;
case 4:Y break;
case 5:R break;
case 6:I break;
case 7:W
}
clr++;
if(clr==8)
clr=0;
pt(d);
cout<<":";
pt(h);
cout<<":";
pt(m);
cout<<":";
pt(s);
s--;
sleep(1);
if(s<0){
m--;
s=59;
}
if(m<0){
h--;
m=59;
}
if(h<0){
d--;
h=23;
}
}
system("cls");
W
cout<<"Over";
while(1){
bp(523);
bp(578);
bp(659);
bp(698);
bp(784);
bp(880);
bp(990);
Beep(1046,400);
Sleep(500);
}
return 0;
}