#include "time.h"
#include "stdio.h"
#include<string.h>
#include<stdlib.h>
#include<windows.h>
struct Time /* 时间结构 */
{
int year; /* 年 */
int month; /* 月 */
int day; /* 日 */
int hour; /*小时*/
int minute; /*分钟*/
int second; /*秒*/
};
typedef struct Time Time;
void begin()
{
//开始界面
printf(" \n");
printf(" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
printf(" @ @ @ \n");
printf(" @ @@@@@@@@@@@@@@@@ @@@@@ @ \n");
printf(" @ @ @ @ @@@ @ \n");
printf(" @ @@@@@@@@@@ @ @ @@@@@@@@@@@@@ \n");
printf(" @ @ @ @ @ @ @ \n");
printf(" @ @@@@@@@@@@@@@@@@ @ @@@@@ @ @ @ \n");
printf(" @ @ @ @ @ @ @@@@@@@@@@@@@ \n");
printf(" @ @ @ @ @ @ @ \n");
printf(" @ @ @ @ @ @ @ @ @ \n");
printf(" @ @ @ @ \n");
printf(" \n");
printf(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! \n");
printf(" ****************************************************** \n");
printf(" \n");
printf(" ******************** 按'enter'进入 ************************** \n");
}
void menu() //一级菜单
{
printf(" _______________________________\n");
printf(" | ****** 1.选择闹铃 ****** |\n");
printf(" | ****** 2.完成 ****** |\n");
printf(" | ****** 3.退出 ****** |\n");
printf(" |_____________________________|\n");
}
void selction( Time *a, int *n,int*b) //选择闹铃并显示相关信息包括年,月,日,时,分,秒,以及开关情况
{
int i;
for(i=0;i<*n;i++)
{
printf(" %d.^O^ ",i+1);
printf("%5d",a[i].year);printf("年");
printf("%3d",a[i].month);printf("月");
printf("%3d",a[i].day);printf("日");
printf("%3d",a[i].hour);printf(" : ");
printf("%3d",a[i].minute);printf(" : ");
printf("%3d",a[i].second);
switch(b[i])
{
case 0:printf(" 关");break;
case 1:printf(" 开");break;
}
printf("\n");
}
}
void menubase()
{
printf(" ##########################################\n"); //二级菜单
printf(" &&&&&& 1.设定 &&&&&&\n");
printf(" &&&&&& 2.取消 &&&&&&\n");
printf(" &&&&&& 3.开关 &&&&&&\n");
printf(" &&&&&& 0.返回 &&&&&&\n");
printf(" ##########################################\n");
}
void setting(Time *a,int i) //设定闹铃
{
printf("the year :");
scanf("%d",&a[i].year);
printf("the month :");
scanf("%d",&a[i].month);
printf("the day :");
scanf("%d",&a[i].day);
printf("the hour :");
scanf("%d",&a[i].hour);
printf("the minute :");
scanf("%d",&a[i].minute);
printf("the second :");
scanf("%d",&a[i].second);
}
void fix(Time *a,int i) //修改闹铃
{
printf("the original :\n");
printf("the year :");
printf("%d",a[i].year);
printf("\n");
printf("the month :");
printf("%d",a[i].month);
printf("\n");
printf("the day :");
printf("%d",a[i].day);
printf("\n");
printf("the hour :");
printf("%d",a[i].hour);
printf("\n");
printf("the minute :");
printf("%d",a[i].minute);
printf("\n");
printf("the second :");
printf("%d",a[i].second);
printf("\n");
printf("fix now\n");
printf("the year :");
scanf("%d",&a[i].year);
printf("\n");
printf("the month :");
scanf("%d",&a[i].month);
printf("\n");
printf("the day :");
scanf("%d",&a[i].day);
printf("\n");
printf("the hour :");
scanf("%d",&a[i].hour);
printf("\n");
printf("the minute :");
scanf("%d",&a[i].minute);
printf("\n");
printf("the second :");
scanf("%d",&a[i].second);
printf("\n");
}
void cancel (Time *a ,int *n,int*b,int i) //取消闹铃
{
*n=*n-1; (a+i-1)->year=(a+(*n))->year;
(a+i-1)->month =(a+(*n))->month;
(a+i-1)->day=(a+(*n))->day;
(a+i-1)->hour=(a+(*n))->hour;
(a+i-1)->second=(a+(*n))->second;
(a+i-1)->minute=(a+(*n))->minute;
*(b+i-1)=*(b+(*n));
selction(a, n ,b);
}
void button(Time *a,int i,int*b) //闹铃开关
{
int m;
printf("*************************\n");
printf("%%%%%% 1.on %%%%%%");printf("\n");
printf("%%%%%% 2.off %%%%%%");printf("\n");
printf("*************************\n");
scanf("%d",&m);
switch(m)
{
case 1:b[i]=1;break;
case 2:b[i]=0;break;
}
}
int compare(int t1y,int t2y,int t3y,int t4y,int t5y,int t6y,
int t1x,int t2x,int t3x,int t4x,int t5x,int t6x )
{
int num;
if(t1y>t1x)
num=1;
else if(t1y<t1x)
num=-1;
else if(t2y>t2x)
num=1;
else if(t2y<t2x)
num=-1;
else if(t3y>t3x)
num=1;
else if(t3y<t3x)
num=-1;
else if(t4y>t4x)
num=1;
else if(t4y<t4x)
num=-1;
else if(t5y>t5x)
num=1;
else if(t5y<t5x)
num=-1;
else if(t6y>t6x)
num=1;
else if(t6y<t6x)
num=-1;
else num=0;
return num;
}
int main(void)
{
int *n;
int m=4,b[4]={0};
int min,i,num,bh,s,j,t,r;
struct tm *ptr1, *ptr2,*ptr3,*ptr4,*ptr5,*ptr6;
Time th,clock[4]={{1990,1,1,00,00,00},{1990,1,1,00,00,00},
{1990,1,1,00,00,00},{1990,1,1,00,00,00}}; //初始闹铃信息
time_t lt;
char str1[80],str2[80],str3[80],str4[80],str5[80],str6[80];n=&m;
begin();
getchar();
repeat :
do{
menu();
scanf("%d",&s);
switch(s) //用do~while语句多次选择菜单
{
case 1:selction(clock, n,b);
scanf("%d",&i);
menubase();
scanf("%d",&t);
switch(t)
{
case 1:setting(clock, i-1);
printf("do you want to fix it ?\n");
printf(" 1: Yes 2: N0\n");
scanf("%d",&r);
switch(r)
{
case 1:fix (clock,i-1);break;
case 2:break;
}
break;
case 2:cancel(clock,n,b,i);break;
case 3:button(clock,i-1,b);break;
case 0:break;
}
case 2:break;
case 3: exit(0);
}
}while(s-2);
for(i=0;i<*n-1;i++)
{
min=i;
for(j=i+1;j<*n;j++)
if(compare(clock[i].year,clock[i].month,clock[i].day,
clock[i].hour,clock[i].minute,clock[i].second,clock[j].year,
clock[j].month,clock[j].day,clock[j].hour,clock[j].minute,clock[j].second)==1)
{
min=j;
th.year=clock[i].year;
th.month=clock[i].month;
th.day=clock[i].day;
th.minute=clock[i].minute;
th.hour=clock[i].hour;
th.second=clock[i].second;
clock[i].year=clock[min].year;
clock[i].month=clock[min].month;
clock[i].day=clock[min].day;
clock[i].hour=clock[min].hour;
clock[i].minute=clock[min].minute;
clock[i].second=clock[min].second;
clock[min].year=th.year;
clock[min].month=th.month;
clock[min].day=th.day;
clock[min].hour=th.hour;
clock[min].minute=th.minute;
clock[min].second=th.second;
bh=b[i];
b[i]=b[min];
b[min]=bh;
}
}
for(i=0;i<*n;i++)
if(
StoneInSnow
- 粉丝: 2
- 资源: 2
最新资源
- (源码)基于Qt和AVR的FestosMechatronics系统终端.zip
- (源码)基于Java的DVD管理系统.zip
- (源码)基于Java RMI的共享白板系统.zip
- (源码)基于Spring Boot和WebSocket的毕业设计选题系统.zip
- (源码)基于C++的机器人与船舶管理系统.zip
- (源码)基于WPF和Entity Framework Core的智能货架管理系统.zip
- SAP Note 532932 FAQ Valuation logic with active material ledger
- (源码)基于Spring Boot和Redis的秒杀系统.zip
- (源码)基于C#的计算器系统.zip
- (源码)基于ESP32和ThingSpeak的牛舍环境监测系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈