#include <iostream>
#include <windows.h>
#include <ctime>
using namespace std;
//定义低音
const int a1 = 131;
const int a2 = 147;
const int a3 = 165;
const int a4 = 175;
const int a5 = 196;
const int a6 = 220;
const int a7 = 247;
//定义中音
const int b1 = 262;
const int b2 = 296;
const int b3 = 330;
const int b4 = 349;
const int b5 = 392;
const int b6 = 440;
const int b7 = 494;
//定义高音
const int c1 = 523;
const int c2 = 587;
const int c3 = 659;
const int c4 = 698;
const int c5 = 784;
const int c6 = 880;
const int c7 = 988;
//定义高二度
const int d1 = 1047;
const int d2 = 1175;
const int d3 = 1319;
const int d4 = 1397;
const int d5 = 1568;
const int d6 = 1760;
const int d7 = 1976;
const int d8 = 2113;
//定义节拍
const int j1 = 230;
const int j2 = 350;
const int j3 = 600;
const int j4 = 1000;
const int j5 = 1500;
const int j0 = 100;
const int j6 = 150;
void hidden()
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cci;
GetConsoleCursorInfo(hOut,&cci);
cci.bVisible=0;/*赋1为显示,赋0为隐藏*/
SetConsoleCursorInfo(hOut,&cci);
}
int m;
void djsq(int d,int m,int n,int o)
{
for(int i=d*3600*24+m*3600+n*60+o;i>=0;i--)
{printf("倒计时:\n%02d天%02d时%02d分%02d秒",i/3600/24,(i%(3600*24))/3600,(i%(3600*24)%3600)/60,(i%(3600*24)%3600)%60);
Sleep(1000);system("cls");
if(i==0)
{
printf("倒计时:\n00天00时00分00秒");
Sleep(800);
aa:
cout<<"\n\n时间到!!";
Beep(c3,j3); //蜂鸣器
Beep(c6,j3);
Beep(c7,j1);
Sleep(90);
Beep(d1,j2);
Beep(c6,j2);
Beep(d4,j2);
//Sleep(100);
Beep(d2,j2);
Beep(d3,j5);
Beep(c3,j3);
//Sleep(90);
Beep(c6,j3);
Beep(c7,j1);
Sleep(90);
Beep(d1,j2);
Beep(c6,j2);
Beep(d4,j2);
Beep(d3,j1);
Beep(d2,j5);
//Beep(c3,j5);
Sleep(700);
Beep(c3,j3);
//Sleep(90);
Beep(c6,j3);
Beep(c7,j1);
Sleep(90);
Beep(d1,j2);
Beep(c6,j2);
Beep(d4,j2);
//Sleep(100);
Beep(d3,j1);
Beep(d2,j2);
Beep(d5,j5);
Sleep(300);
Beep(c3,j1);
//Sleep(90);
Beep(c6,j3);
Beep(c7,j1);
Sleep(90);
Beep(d1,j2);
Beep(c6,j2);
Beep(d4,j2);
//Sleep(100);
Beep(d3,j2);
Beep(d2,j2);
Beep(d6,j5);
system("cls");
goto aa;
}
}
}
int main()
{
hidden();
//begin:
int set;
system("mode con cols=68 lines=22");
int a,b,c,d,m;
int i = 1;
while(i<=20)
{
cout<<"\t\t\t倒计时器\n";
cout<<"请输入天:\n";
cin>>a;
cout<<"请输入时:\n";
cin>>b;
cout<<"请输入分:\n";
cin>>c;
cout<<"请输入秒:\n";
cin>>d;
m=a*3600*24+b*3600+c*60+d;
printf("您输入的时间为%02d天%02d时%02d分%02d秒\n",m/3600/24,(m%(3600*24))/3600,(m%(3600*24)%3600)/60,(m%(3600*24)%3600)%60);
//cout<<"您输入的时间为"<<m/3600/24<<"天"<<(m%(3600*24))/3600<<"小时"<<(m%(3600*24)%3600)/60<<"分"<<(m%(3600*24)%3600)%60<<"秒"<<endl;
cout<<"确认请按 1 ,否则请按 0 : "<<endl;
cin>>set;
if(set)
{
break;
}
system("cls");
i++;
}
djsq(a,b,c,d);
//goto begin;
return 0;
}
提示:此倒计时结束时有声音