#include "..incconfig.h"
#define STACKSIZE 256
#define x_line 160
#define y_line 80
OS_STK_DATA stk;
extern GUI_FONT GUI_Font8x16;
OS_EVENT*Send_D7light_Sem;
OS_EVENT*Send_LCD_Sem;
OS_EVENT*Key_Mbox;
I8 Hour[3],Min[3],Sec[3];
I8 hour = 15%12, min = 20, sec = 40;
I8 YEA1[3],YEA2[3],MON[3],DAY[3];
int yea1 = 20,yea2=11, mon = 6, day = 23;
int SpaceXS[61]={160,165,170,175,180,185,
189,193,197,201,205,
206,207,208,209,210,
209,208,207,206,205,
201,197,193,189,185,
180,175,170,165,160,
155,150,145,140,135,
131,127,123,119,115,
114,113,112,111,110,
111,112,113,114,115,
119,123,127,131,135,
140,145,150,155,160,
},
SpaceYS[61]={30,31,32,33,34,
35,39,43,47,51,
55,60,65,70,75,
80,85,90,95,100,
105,109,113,117,121,
125,126,127,128,129,
130,129,128,127,126,
125,121,117,113,109,
105,100,95,90,85,
80,75,70,65,60,
55,51,47,43,39,
35,34,33,32,31,30},
SpaceXM[61]={160,164,168,172,176,180,183,186,189,192,195,196,197,198,199,200,199,198,197,196,195,192,189,186,183,180,176,172,168,164,160,156,152,148,144,140,137,134,131,128,125,124,123,122,121,120,121,122,123,124,125,128,131,134,137,140,144,148,152,156,
160 },
SpaceYM[61]={40,41,42,43,44,45,48,51,54,57,
60,64,68,72,76,80,84,88,92,96,100,103,106,109,112,115,116,117,118,119,120,119,118,117,116,115,112,109,106,103,100,96,92,88,84,80,76,72,68,64,60,57,54,51,48,45,44,43,42,41,4},
SpaceXH[13]={160,175,185,190,185,175,160,145,135,130,135,145,160}, SpaceYH[13]={50,55,65,80,95,105,110,105,95,80,65,55,50},
*Placex=&SpaceXS[40],*Placey=&SpaceYS[40],*Placexm=&SpaceXM[20],*Placeym=&SpaceYM[20], *Placexh=&SpaceXH[15%12],*Placeyh=&SpaceYH[15%12];
void show(I8 s)
{
if(s%5==0)
{
Set_Color(GUI_YELLOW);
Set_Font(&GUI_Font8x16);
Disp_String ("0862310104",10,30);
Set_Font(&GUI_Font8x16);
Disp_String ("0862310121",10,10);}
else if(s%5==1)
{
Set_Color(GUI_YELLOW);
Set_Font(&GUI_Font8x16);
Disp_String ("guxin ",10,10);
Set_Font(&GUI_Font8x16);
Disp_String ("fanjuan ",10,30);
}
else if(s%5==2)
{
Set_Color(GUI_YELLOW);
Set_Font(&GUI_Font8x16);
Disp_String("0862310104",10,30);
Set_Font(&GUI_Font8x16);
Disp_String("0862310121",10,10);
}
else if(s%5==3)
{
Set_Color(GUI_YELLOW);
Set_Font(&GUI_Font8x16);
Disp_String ("fanjuan ",10,30);
Set_Font(&GUI_Font8x16);
Disp_String ("guxin ",10,10);
}
else if(s%5==4)
{
Set_Color(GUI_YELLOW);
Set_Font(&GUI_Font8x16);
Disp_String ("S3C44BOX ",10,10);
Set_Font(&GUI_Font8x16);
Disp_String ("LCD CLOCK ",10,30);
}
}
void Shows()
{
show(sec);
Set_Color(GUI_GRAY); //擦除上一秒 Draw_Line(x_line,y_line,*Placex,*Placey);
Placex=Placex+1;
Placey=Placey+1;
Set_Color(GUI_YELLOW); //显示下一秒的
Draw_Line(x_line,y_line,*Placex,*Placey);
Set_Color(GUI_RED); //显示下一分的 DrawLine(x_line,y_line,*Placexm,*Placeym);
Set_Color(GUI_GREEN); //显示下一时的 Draw_Line(x_line,y_line,*Placexh,*Placeyh); if(Placex==&SpaceXS[60]&&Placey==&SpaceYS[60])
{
Placex=&SpaceXS[0];
Placey=&SpaceYS[0];
}
}
void Showm()
{
Set_Color(GUI_GREEN);
Set_Color(GUI_RED);
Set_Color(GUI_YELLOW);
Set_Color(GUI_GRAY); //擦除上一分的
DrawLine(x_line,y_line,*Placexm,*Placeym);
Placexm=Placexm+1;
Placeym=Placeym+1;
Set_Color(GUI_RED); //显示下一分的 DrawLine(x_line,y_line,*Placexm,*Placeym);Set_Color(GUI_GREEN);//显示下一时的 Draw_Line(x_line,y_line,*Placexh,*Placeyh); if(Placexm==&SpaceXM[60]&&Placeym==&SpaceYM[60])
{
Placexm=&SpaceXM[0];
Placeym=&SpaceYM[0];
}
}
void Showh()
{
Set_Color(GUI_YELLOW);
Set_Color(GUI_GREEN);
Set_Color(GUI_RED);
Set_Color(GUI_GRAY); //擦除上一时的 DrawLine(x_line,y_line,*Placexh,*Placeyh);
Placexh=Placexh+1;
Placeyh=Placeyh+1;
Set_Color(GUI_GREEN);//显示下一时的 DrawLine(x_line,y_line,*Placexh,*Placeyh); if(Placexh==&SpaceXH[12]&&Placeyh==&SpaceYH[12])
{
Placexh=&SpaceXH[0];
Placeyh=&SpaceYH[0];
}
}
void Shouw_Cricle() // 整 点
{
Set_Color(GUI_YELLOW);
Fill_Circle (160, 30,2); // 12点(x,y,r)
Fill_Circle (135, 35,2); // 11 点(x,y,r)
Fill_Circle (115, 55,2); // 10 点(x,y,r)
Fill_Circle (110, 80,2); // 9 点(x,y,r)
Fill_Circle (115, 105,2); // 8 点(x,y,r)
Fill_Circle (135, 125,2); // 7 点(x,y,r)
Fill_Circle (160, 130,2); // 6 点(x,y,r)
Fill_Circle (185, 125,2); // 5 点(x,y,r)
Fill_Circle (205, 105,2); // 4 点(x,y,r)
Fill_Circle (210, 80,2); // 3 点(x,y,r)
Fill_Circle (205, 55,2); // 2点(x,y,r)
Fill_Circle (185, 35,2); // 1点(x,y,r)
}
void Show_ht()
{
Set_Color(GUI_GRAY);
Fill_Circle (160,80,54);
}
void ChangeForm(char
time[],char time)
{
Time[0] = time / 10 + 48;
Time[1] = time % 10 + 48;
Time[2] = ' ';
}
void Display_Time(char x,char y)
{
ChangeForm(Hour, hour);
ChangeForm(Min, min);
ChangeForm(Sec, sec);
ChangeForm(MON, mon);
ChangeForm(DAY, day);
ChangeForm(YEA1, yea1);
ChangeForm(YEA2, yea2);
Disp_String (Hour,x,160);
Disp_String (":",x + 16,160);
Disp_String (Min,x + 24,160);
Disp_String (":",x + 40,160);
Disp_String (Sec,x + 48,160);
Disp_String (YEA1,x , 180);
Disp_String (YEA2,x +16,180);
Disp_String ("-",x + 32,180);
Disp_String (MON,x + 40,180);
Disp_String ("-",x + 56,180);
Disp_String (DAY,x + 64,180);
}
void Show_Color()
{
Set_Color( GUI_BLUE );
Fill_Rect(0,0,319,239);
Set_Color(GUI_BLUE);
Set_BkColor (GUI_BLUE);
Fill_Rect(0,0,319,2);
Fill_Rect(0,0,2,239);
Fill_Rect(0,237,319,239);
Fill_Rect(317,0,319,239);
}
void Task_1(void *pdata)
{
Rtc_Tick_Init();
OSTaskCreate(Task_2, (void *)0, (OS_STK *)&Stack_Task_2[(STACKSIZE*3) - 1], 9); //在任务里创建另一个任务
for(;;)
{ OSTimeDly(50); //时钟屏幕显示
}
}
/*******主 函 数***********/
void Main(void)
{
Target_Init(); //
ARMII实验系统的初始化,包括CPU板
GUI_Init();
OSInit();
OSTaskCreate(Task_1, (void *)0, (OS_STK *)&Stack_Task_1[STACKSIZE - 1], 5); //创建任务一
OSStart();
}
/*- 函数名称 : Task_2(void *pdata)
- 函数说明 : GUI任务,优先级为9
- 输入参数 : pdata
- 输出参数 : 无*/
void Task_2(void *pdata)
{
for(;;)
{
/*****全屏颜 {MOD}设计*******/
/*******时 钟 位 置*******/
Show_Color();
Show_ht();
/******点 的 坐 标********/
Shouw_Cricle();
/**定背景颜 {MOD}API**/
Set_Color(GUI_YELLOW); //显示
DrawLine(x_line,y_line,*Placex,*Placey);
Display_Time(130, 160);//时间
do
{
Delay(1200);
sec++;
Shows();
if (sec >= 60)
{
sec = 0;
min++;
Showm();
if (min >= 60)
{
min = 0;
hour++;
Showh();
if (hour >= 23)
{
hour = 0;
day++;
if(day >=32)
{
day = 1;
mon++;
if(mon >= 13)
{
mon = 1;
yea1++;
}
}
}
}
}
DisplayTime(130, 160);//时间 日期
}while(1);
}
}
OS_STK Stack_Task_1[STACKSIZE];
OS_STK Stack_Task_2[STACKSIZE*3];
/*- 函数名称 : Task_3(void *pdata)
- 函数说明 : GUI任务,优先级为56
- 输入参数 : pdata
- 输出参数 : 无*/
void Task_3(I8 s)
{
I8 display;
for(;;)
{
Delay(100);
display++;
Set_Color(GUI_RED);
if(display==1000)
{
display=0;
}
}
}
*/
/*这是我写过的一段 看看对你有帮助吗!!!
*********************************************************
* 头文件
*********************************************************
*/
#include <stdio.h>
#include <stdlib.h>
#include "44b0x.h"
#include "44bConfig.h"
#include "define.h"
#include "LCD_Control.h"
#include "LCD_DispHZ.h"
#include "key.h"
#include "uart.h"
#include "beep.h"
#define MAXSIZE 5//定义航线量的最大值
/*
*********************************************************
* 变量
*********************************************************
*/
char *TXT[60] =
{
"00","01","02","03","04","05","06","07","08","09","10",
"11","12","13","14","15","16","17","18","19","20",
"21","22","23","24","25","26","27","28","29","30",
"31","32","33","34","35","36","37","38","39","40",
"41","42","43","44","45","46","47","48","49","50",
"51","52","53","54","55","56","57","58","59"
};
char *NIAN[60] =
{
"2000","2001","2002","2003","2004","2005","2006","2007","2008","2009","2010",
"2011","2012","2013","2014","2015","2016","2017","2018","2019","2020",
"2021","2022","2023","2024","2025","2026","2027","2028","2029","2030",
"2031","2032","2033","2034","2035","2036","2037","2038","2039","2040",
"2041","2042","2043","2044","2045","2046","2047","2048","2049","2050"};
char *TIME[7]=
{
"一","二","三","四","五","六","日"
};
char *air[MAXSIZE][6]={
{"北京","1","BJ001","2014,06,22",100,100},
{"上海","2","SH002","2014,06,22",100,100},
{"厦门","3","XM003","2014,06,22",100,100},
{"广州","4","GZ004","2014,06,22",100,100},
{"福州","5","FZ005","2014,06,22",100,100}
};
int h=0,m=0,s=0,leap_year=0; //时钟的三个变量,leap_year判断下一年是否为闰年的变量
char key;
int year=16,month=4,day=16,week=5; //初始时间为2016年4月16日星期六
//闰年判断(判断当前年份的下一年是否为润年)
void leap_year_judge()
{
if((((year+1)%4==0)&&((year+1)%100!=0))||(year+1)%400==0)
leap_year=1;
else
leap_year=0;
}
//界面显示
void showLcd(void)
{
Lcd_GotoXY(4,1);
Lcd_printf(RED,"%s","********************************");
Lcd_GotoXY(4,3);
Lcd_printf(RED,"%s","************设置时间************");
Lcd_GotoXY(4,5);
Lcd_printf(RED,"%s","********************************");
for(i;i<=11;i++)
{
Lcd_GotoXY(4,i);
Lcd_printf(RED,"%s","* *");
}
Lcd_GotoXY(4,12);
Lcd_printf(RED,"%s","********************************");
}
//显示年、月、日、星期及时间
void showTime()
{
Lcd_GotoXY(8,10);
Lcd_printf(GREEN,"%s",NIAN[year]);
Lcd_GotoXY(12,10);
Lcd_printf(GREEN,"年");
Lcd_GotoXY(15,10);
Lcd_printf(GREEN,"%s",TXT[month]);
Lcd_GotoXY(18,10);
Lcd_printf(GREEN,"月");
Lcd_GotoXY(21,10);
Lcd_printf(GREEN,"%s",TXT[day]);
Lcd_GotoXY(24,10);
Lcd_printf(GREEN,"日");
Lcd_GotoXY(27,10);
Lcd_printf(GREEN,"星期");
Lcd_GotoXY(31,10);
Lcd_printf(GREEN,"%s",TIME[week]);
Lcd_GotoXY(24,11);
Lcd_printf(GREEN,"%s",TXT[s]);
Lcd_GotoXY(21,11);
Lcd_printf(GREEN,":");
Lcd_GotoXY(18,11);
Lcd_printf(GREEN,"%s",TXT[m]);
Lcd_GotoXY(15,11);
Lcd_printf(GREEN,":");
Lcd_GotoXY(12,11);
Lcd_printf(GREEN,"%s",TXT[h]);
}
//设置时间
void setTime()
{
int i = 0;
while(1)
{
LCD_Clear();
Delay(1000);
showLcd();
showTime();
key=Key_Get();
if(key!=FALSE) //如果按键按下
{
Uart_Printf(" You press key value : %c", key);
switch(key)
{
case '2': //按下2,分钟加1
m=m+1;
if(m==60)//分钟超过59分钟(不含59分钟)则从0分钟开始重新记数
{
m=0;
h++;
}
break;
case '1'://按下1,小时加1
h=h+1;
if(h==24)//小时超过23小时(不含23小时)则从0小时开始重新记数
{
h=0;
day++;
week++;
}
break;
case '*'://按下*,年加1
{
if(leap_year == 1)//下一年若是润年,当前星期加2
{
if(week <= 4)
week = week+2;
else
{
if(week == 5)
week = 0;
else
if(week == 6)
week = 1;
}
}
else
week++;//下一年若不是润年,当前星期加1
year=year+1;//年份加1
if(year==51)//年超过2050年(不含2050年)则从2000年开始重新记数
{
year=0;
}
}
break;
case '0'://按下0,月加1
{
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)//大月星期加3天
{
if(week <= 3)
week += 3;
else
{
if(week == 4)
week = 0;
else
{
if(week == 5)
week = 1;
else
{
if(week == 6)
week = 2;
}
}
}
}
if(month==4||month==6||month==9||month==11)//小月星期加2天
{
if(week <= 4)
week += 2;
else
{
if(week == 5)
week = 0;
else
if(week == 6)
week = 1;
}
}
if(month==2&&leap_year==1)//润年星期加1天
{
week++;
}
month=month+1;//月份加1
if(month==13)//年不超过12月(不含12月)则从1月开始重新记数
{
month=1;
year++;
}
}
break;
case '3'://按下3,日加1
{
day++;
if((month==1||month==3||month==5||month==7||month==8||month==10||month==12)&&(day==32))//大月每日超过31天(不含31日 )则从1日开始重新记数
{
month++;
day=1;
}
if((month==4||month==6||month==9||month==11)&&(day==31))//小月每日超过30天(不含30日 )则从1日开始重新记数
{
month++;
day=1;
}
if(month==2)
{
if(leap_year==0&&day==29)//2月每日超过28天(不含28日 )则从1日开始重新记数
{
month++;
day=1;
}
if(leap_year==1&&day==30)//2月每日超过28天(不含28日 )则从1日开始重新记数
{
month++;
day=1;
}
}
week += 1;
if(week==7)//星期超过周日(不含周日)则从周一开始重新记数
{
week=0;
}
}
break;
default:
i=1;
break;
}
}
if(i == 1)
{break;}
}
}
//系统边框
void showSystem()
{
int i = 4;
Lcd_GotoXY(4,1);
Lcd_printf(RED,"%s","================================");
Lcd_GotoXY(4,2);
Lcd_printf(RED,"%s","* 欢迎来到福州航空公司 *");
Lcd_GotoXY(4,3);
Lcd_printf(RED,"%s","================================");
for(i;i<=11;i++)
{
Lcd_GotoXY(4,i);
Lcd_printf(RED,"%s","* *");
}
Lcd_GotoXY(4,12);
Lcd_printf(RED,"%s","================================");
}
//开始界面
void showStart()
{
Lcd_GotoXY(4,4);
Lcd_printf(GREEN,"%s"," 1.xxx ");
Lcd_GotoXY(4,5);
Lcd_printf(GREEN,"%s"," 2.xx ");
Lcd_GotoXY(4,6);
Lcd_printf(GREEN,"%s"," 3.xxxx ");
Lcd_GotoXY(4,7);
Lcd_printf(GREEN,"%s"," 4.xxxx ");
Lcd_GotoXY(4,8);
Lcd_printf(GREEN,"%s"," 5.系统设置 ");
Lcd_GotoXY(4,9);
Lcd_printf(GREEN,"%s"," 0.退出系统 ");
}
//航线信息总览
void display()
{
while(1)
{
LCD_Clear();
showSystem();
Lcd_GotoXY(4,5);
Lcd_printf(GREEN,"终点站名 航班号 飞机号 飞行日期 乘员定额 余票量 ");
int i=0,j=0;
for(i;i<5;i++)
{
Lcd_GotoXY(4,6+i);
Lcd_printf(GREEN,"%5s %3s %s %4s %5d %12d ",air[i][0],air[i][1],air[i][2],air[i][3],air[i][4],air[i][5]);
//printf("%5s %3s %s %4s %5d %12d ",air[i][0],air[i][1],air[i][2],air[i][3],air[i][4],air[i][5]);
}
Lcd_GotoXY(4,11);
Lcd_printf(GREEN," 请按任意键返回上一单元 ");
key = Key_Get();
if(key!=FALSE) //如果按键按下
{
Uart_Printf(" You press key value : %c", key);
j=1;
if(j == 1)
{
break;
}
}
}
}
//查询航线
void search()
{
while(1)
{
int i=0,j=0,a=0;
Delay(150000);
LCD_Clear();
showSystem();
key = Key_Get();
Lcd_GotoXY(4,6);
Lcd_printf(GREEN," 请输入要查询的航班号:");
Lcd_GotoXY(4,11);
Lcd_printf(GREEN," 请按“#”返回上一单元 ");
if(key!=FALSE) //如果按键按下
{
Uart_Printf(" You press key value : %c", key);
Lcd_GotoXY(4,6);
Lcd_printf(GREEN," %s",key);
switch(key)
{
case '1':
i=1;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN,"%5s %3s %s %4s %5d %12d ",air[i][0],air[i][1],air[i][2],air[i][3],air[i][4],air[i][5]);
break;
case '2':
i=2;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN,"%5s %3s %s %4s %5d %12d ",air[i][0],air[i][1],air[i][2],air[i][3],air[i][4],air[i][5]);
break;
case '3':
i=3;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN,"%5s %3s %s %4s %5d %12d ",air[i][0],air[i][1],air[i][2],air[i][3],air[i][4],air[i][5]);
break;
case '4':
i=4;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN,"%5s %3s %s %4s %5d %12d ",air[i][0],air[i][1],air[i][2],air[i][3],air[i][4],air[i][5]);
break;
case '5':
i=5;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN,"%5s %3s %s %4s %5d %12d ",air[i][0],air[i][1],air[i][2],air[i][3],air[i][4],air[i][5]);
break;
case '#':
j=1;
break;
default:
Lcd_GotoXY(4,8);
Lcd_printf(GREEN," 输入不正确,请重新输入航班号");
break;
}
if(j == 1)
{
break;
}
}
}
}
//订票
void order()
{
while(1)
{
int j=0;
Delay(150000);
LCD_Clear();
showSystem();
key = Key_Get();
Lcd_GotoXY(4,6);
Lcd_printf(GREEN," 请输入要订购的航班号:");
Lcd_GotoXY(4,11);
Lcd_printf(GREEN," 请按“#”返回上一单元 ");
if(key!=FALSE) //如果按键按下
{
Uart_Printf(" You press key value : %c", key);
Lcd_GotoXY(4,6);
Lcd_printf(GREEN," %s",key);
switch(key)
{
case '1':
air[0][5] -= 1;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN," 购票成功!");
break;
case '2':
air[1][5] -= 1;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN," 购票成功!");
break;
case '3':
air[2][5] -= 1;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN," 购票成功!");
break;
case '4':
air[3][5] -= 1;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN," 购票成功!");
break;
case '5':
air[4][5] -= 1;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN," 购票成功!");
break;
case '#':
j=1;
break;
default:
Lcd_GotoXY(4,8);
Lcd_printf(GREEN," 输入不正确,请重新输入航班号");
break;
}
if(j == 1)
{
break;
}
}
}
}
//退票
void returnTicket()
{
while(1)
{
int j=0;
Delay(150000);
LCD_Clear();
showSystem();
key = Key_Get();
Lcd_GotoXY(4,6);
Lcd_printf(GREEN," 请输入要退订的航班号:");
Lcd_GotoXY(4,11);
Lcd_printf(GREEN," 请按“#”返回上一单元 ");
if(key!=FALSE) //如果按键按下
{
Uart_Printf(" You press key value : %c", key);
Lcd_GotoXY(4,6);
Lcd_printf(GREEN," %s",key);
switch(key)
{
case '1':
air[0][5] += 1;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN," 退票成功!");
break;
case '2':
air[1][5] += 1;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN," 退票成功!");
break;
case '3':
air[2][5] += 1;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN," 退票成功!");
break;
case '4':
air[3][5] += 1;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN," 退票成功!");
break;
case '5':
air[4][5] += 1;
Lcd_GotoXY(4,8);
Lcd_printf(GREEN," 退票成功!");
break;
case '#':
j=1;
break;
default:
Lcd_GotoXY(4,8);
Lcd_printf(GREEN," 输入不正确,请重新输入航班号");
break;
}
if(j == 1)
{
break;
}
}
}
}
//退出系统
void exit()
{
while(1)
{
LCD_Clear();
showSystem();
Lcd_GotoXY(10,8);
Lcd_printf(GREEN,"感谢您使用本系统,再见!");
}
}
//主函数
void Main(void)
{
Port_Init();
LCD_Init();
Isr_Init();
Uart_Init(0,57600);
Key_Init();
Beep_Init();
//leap_year_judge();//闰年判断
while(1)
{
Delay(2000);
showSystem();
showStart();
showTime();
key = Key_Get();
if(key!=FALSE) //如果按键按下
{
Uart_Printf(" You press key value : %c", key);
switch(select)
{
case '1': display();break;
case '2': search();break;
case '3': order();break;
case '4': returnTicket();break;
case '5': setTime();break;
case '0': exit();break;
default:
break;
}
}
Delay(28000);
LCD_Clear();
showSystem();
showStart();
showTime();
if(year==51)//年超过2050年(不含2050年)则从2000年开始重新记数
{
year=0;
}
if(week==7)//星期超过周日(不含周日)则从周一开始重新记数
{
week=0;
}
s++;
if(s==60)//秒超过59秒(不含59秒)则从0秒开始重新记数
{
s=0;
m++;
}
if(m==60)//分钟超过59分钟(不含59分钟)则从0分钟开始重新记数
{
m=0;
h++;
}
if(h==24)//小时超过23小时(不含23小时)则从0小时开始重新记数
{
h=0;
day++;
week++;
}
if((month==1||month==3||month==5||month==7||month==8||month==10||month==12)&&(day==32))//大月每日超过31天(不含31日 )则从1日开始重新记数
{
month++;
day=1;
}
if((month==4||month==6||month==9||month==11)&&(day==31))//小月每日超过30天(不含30日 )则从1日开始重新记数
{
month++;
day=1;
}
if(month==2)
{
if(leap_year==0&&day==29)//2月每日超过28天(不含28日 )则从1日开始重新记数
{
month++;
day=1;
}
if(leap_year==1&&day==30)//2月每日超过28天(不含28日 )则从1日开始重新记数
{
month++;
day=1;
}
}
if(month==13)//年不超过12月(不含12月)则从1月开始重新记数
{
month=1;
year++;
}
}
}
一周热门 更多>