【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《c++2012高考倒计时程序》,欢迎阅读!
为还在高考的同学写的高考倒计时 //time.h //头文件;
#include using namespace std; class riqi {
public:
intmonthofday(int m) {
switch(m) { case 1: case 3: case 5: case 7: case 7: case 8: case 10: case 12: return 31; case 4: case 6: case 9: case 11: return 30; case 2: if((year%4==0&&year%100!=0)||year%400==0) return 29;
else return 28;} } voiddays(int year,int month,int day) { boolflag=(year==2012&&month==6&&day==7); int n=0;
for(n=0;(flag==0);n++) { day++; if(day>monthofday(month)) { day=1; month++; } if(month>12)
{ year++; month=1; }
flag=(year==2012&&month==6&&day==7); } cout<<"----------------------------"< cout<<"距高考时间为:"<天"; } voidtimes(); private: intyear; intmonth; intday; };
// main.cbb 主程序
#include using namespace std; #include #include "time.h" #include int main()
{ //第一步先调用系统时间; while(1){ time_ttimer; structtm* p; time(&timer); p= localtime(&timer); cout<<"系统时间为"< cout<tm_year+1900<<"年"<tm_mon+1<<"月"<tm_mday<<"日"<tm_hour<<"时"<tm_min<<"分"<tm_sec<<"秒"< inta,b,c; riqidate; date.days(p->tm_year+1900,p->tm_mon+1,p->tm_mday); a=23-(p->tm_hour),b=59-(p->tm_min),c=59-(p->tm_sec); c++;
if(c==60) { c=0; b++; if(b==60) { b=0; a++; } }
cout<时"<分"<秒"< cout<<"加油啦小伙子们姑娘们"< cout<<"东哥制作"< Sleep(1000); system("cls"); } }
本文来源:https://www.wddqxz.cn/a107df4dcf84b9d528ea7a20.html