6 日历记事本
要求:带有日程提醒功能的日历。
显示信息:用户可以向前查询前一个月的日期,也可以向后查询下一个月的日期。
定时提醒:用户可以针对某一天来添加,删除和编辑这一天的日程提醒信息,当系统时间和提醒时间相吻合时,给出具有提示信息的对话框。
查询信息:用户可以查询到某个月的所有的提示信息。
程序:
/***************************
*** 日历记事本 ****
&&&&&&&&&&&&&&&&&&&&&&&&& */
#include<iostream>
#include<iomanip>
#include<cstring>
#include<string>
using namespace std;
struct dates
{
int month;
int day[6][7];
char * next1;//指向提醒信息的指针;
};//定义一个结构体dates;
struct not
{
int months;
int days;
char messages[250];
};//存放信息的结构体;
void f_month(int s[6][7],int month)//查询月份函数!!!!!!!
{
int n,x,i,j;
if((month==9)||(month==12))
n=0;
else if((month==4)||(month==7))
n=1;
else if((month==1)||(month==10))
n=2;
else if(month==5)
n=3;
else if(month==8)
n=4;
else if(month==6)
n=6;
else
n=5;
if(month==2)
x=28;
else if((month==4)||(month==6)||(month==9)||(month==11))
x=30;
else
x=31;
for(i=0;i<6;i++)
{
if(i==0)
{
if(n==0)
for(j=0;j<6;j++)
{s[i][0]=1;
s[i][j+1]=s[i][j]+1;}
else
{
for(j=0;j<n;j++)
s[i][j]=0;
for(j=n;j<7;j++)
s[i][j]=s[i][j-1]+1;
}
}
else
for(j=0;j<6;j++)
{
s[i][0]=s[i-1][6]+1;
if(s[i][0]==x)
break;
else
{
s[i][j+1]=s[i][j]+1;
if(s[i][j+1]==x)
break;
}
}
}
}
void out_month(int calendar[6][7],int month)//输出月份函数!!!!!!!
{
int i,j,x;
if(month==2)
x=28;
else if((month==4)||(month==6)||(month==9)||(month==11))
x=30;
else
x=31;
cout<<" 一 二 三 四 五 六 日"<<endl;
for(i=0;i<6;i++)
{
for(j=0;j<7;j++)
{
if((calendar[i][j]>0)&&(calendar[i][j]<=x))
cout<<setw(4)<<calendar[i][j];
else
cout<<setw(4)<<'\0';
}
cout<<endl;
}
}
not addition(int month,int day) //建立一个节点
{
not not_1={0,0,'\0'};
not*head;
head=¬_1;
head->months=month;
head->days=day;
cout<<"请输入提醒信息: ";
cin>>head->messages;
return not_1;
}
int main() //main函数!! !
{
dates calendar;
dates* r;
r=&calendar;
not collect[12][31];
not *h;
int i,j;
int m,n;//m月!,n天
cout<<endl;
cout<<endl;
cout<<setw(37)<<"welcome"<<endl;
cout<<endl;
cout<<endl;
cout<<setw(40)<<"日 历 表"<<endl;
cout<<endl;
cout<<setw(50)<<"-------------------------------"<<endl;
cout<<endl;
int choice;
cout<<setw(40)<<"# 1.查询日历请按【1】 ";
cout<<"& 2.查询事项请按【2】 "<<endl;
cout<<endl;
cout<<endl;
cout<<setw(40)<<"* 3.编辑事项请按【3】 ";
cout<<"$ 4.退出系统请按【4】 "<<endl;
cin>>choice;
while(choice!=4)
{
while(choice==1)//查询日历
{
cout<<"请输入查询的月份:2014年/ ";
cin>>r->month;
f_month(r->day,r->month);
out_month(r->day,r->month);
cout<<"继续查询请按【1】"<<endl;
cout<<"返回主界面请按【2】"<<endl;
cin>>choice;
if(choice!=1)
{
cout<<setw(40)<<"# 1.查询日历请按【1】 ";
cout<<"& 2.查询事项请按【2】 "<<endl;
cout<<endl;
cout<<endl;
cout<<setw(40)<<"* 3.编辑事项请按【3】 ";
cout<<"$ 4.退出系统请按【4】 "<<endl;
cin>>choice;
}
}
while(choice==2)//查询事项
{
int cheak;
cout<<"1.查询全部事项按【1】"<<endl;
cout<<endl;
cout<<"2.查询某天事项按【2】"<<endl;
cout<<endl;
cout<<"3.查询某月事项按【3】"<<endl;
cout<<endl;
cout<<"4.返回上一级请按【4】"<<endl;
cin>>cheak;
if(cheak==4)
{
cout<<endl;
cout<<setw(40)<<"# 1.查询日历请按【1】 ";
cout<<"& 2.查询事项请按【2】 "<<endl;
cout<<endl;
cout<<endl;
cout<<setw(40)<<"* 3.编辑事项请按【3】 ";
cout<<"$ 4.退出系统请按【4】 "<<endl;
cin>>choice;
}
while(cheak==1)
{
cout<<"全部事项: "<<endl;
for(i=0;i<12;i++)
for(j=0;j<31;j++)
{
h=&collect[i][j];
if((h->days>0)&&(h->days<=31))
{
cout<<h->months<<"月 "<<h->months<<"日 提醒你:"<<h->messages<<endl;
}
}
cout<<endl;
cout<<endl;
cout<<"返回按【4】返回 ";
cin>>cheak;
cout<<endl;
cout<<"1.查询全部事项按【1】"<<endl;
cout<<endl;
cout<<"2.查询某天事项按【2】"<<endl;
cout<<endl;
cout<<"3.查询某月事项按【3】"<<endl;
cout<<endl;
cout<<"4.返回主菜单【4】"<<endl;
cin>>cheak;
cout<<endl;
if(cheak==4)
{
cout<<endl;
cout<<setw(40)<<"# 1.查询日历请按【1】 ";
cout<<"& 2.查询事项请按【2】 "<<endl;
cout<<endl;
cout<<endl;
cout<<setw(40)<<"* 3.编辑事项请按【3】 ";
cout<<"$ 4.退出系统请按【4】 "<<endl;
cin>>choice;
}
}
while(cheak==2)
{
cout<<"需要查询事项月份: ";
cin>>m;
cout<<"输入查询事项日期: ";
cin>>n;
h=&collect[m-1][n-1];
if((h->days>0)&&(h->days<=31))
cout<<h->months<<"月 "<<h->days<<"日 "<<h->messages<<endl;
else
cout<<'\0'<<" "<<'\0'<<" "<<"没有特别的事,亲!"<<endl;
cout<<"继续查询按【2】"<<endl;
cout<<"返回请按【4】"<<endl;
cin>>cheak;
cout<<endl;
if(cheak!=2)
{
cout<<endl;
cout<<"1.查询全部事项按【1】"<<endl;
cout<<endl;
cout<<"2.查询某天事项按【2】"<<endl;
cout<<endl;
cout<<"3.查询某月事项按【3】"<<endl;
cout<<endl;
cout<<"4.返回主菜单【4】"<<endl;
cin>>cheak;
cout<<endl;
}
if(cheak==4)
{
cout<<setw(40)<<"# 1.查询日历请按【1】 ";
cout<<"& 2.查询事项请按【2】 "<<endl;
cout<<endl;
cout<<endl;
cout<<setw(40)<<"* 3.编辑事项请按【3】 ";
cout<<"$ 4.退出系统请按【4】 "<<endl;
cin>>choice;
}
}
while(cheak==3)
{
cout<<"输入查询月份: ";
cin>>i;
for(j=0;j<31;j++)
{
h=&collect[i][j];
if((h->days>0)&&(h->days<=31))
cout<<h->days<<"月 "<<h->months<<"日 "<<h->messages<<endl;
}
for(j=0;j<31;j++)
{
h=&collect[i][j];
if((h->days>0)&&(h->days<=31))
break;
else if((!(h->days>0)&&(h->days<=31))&&(j==30))
cout<<"该月 "<<"没有什么特别的事,亲!"<<endl;
}
cout<<"继续查询按【3】"<<endl;
cout<<"返回请按【4】"<<endl;
cin>>cheak;
if(cheak!=3)
{
cout<<endl;
cout<<"1.查询全部事项按【1】"<<endl;
cout<<endl;
cout<<"2.查询某天事项按【2】"<<endl;
cout<<endl;
cout<<"3.查询某月事项按【3】"<<endl;
cout<<endl;
cout<<"4.返回主菜单【4】"<<endl;
cin>>cheak;
cout<<endl;
}
if(cheak==4)
{
cout<<endl;
cout<<setw(40)<<"# 1.查询日历请按【1】 ";
cout<<"& 2.查询事项请按【2】 "<<endl;
cout<<endl;
cout<<endl;
cout<<setw(40)<<"* 3.编辑事项请按【3】 ";
cout<<"$ 4.退出系统请按【4】 "<<endl;
cin>>choice;
}
}
}
while(choice==3)//编辑事项
{
int edit;
cout<<endl;
cout<<"1.添加事项按【1】"<<endl;
cout<<endl;
cout<<"2.编辑事项按【2】"<<endl;
cout<<endl;
cout<<"3.删除事项按【3】"<<endl;
cout<<endl;
cout<<"4.返回主菜单【4】"<<endl;
cin>>edit;
cout<<endl;
if(edit==4)
{
cout<<setw(40)<<"# 1.查询日历请按【1】 ";
cout<<"& 2.查询事项请按【2】 "<<endl;
cout<<endl;
cout<<endl;
cout<<setw(40)<<"* 3.编辑事项请按【3】 ";
cout<<"$ 4.退出系统请按【4】 "<<endl;
cin>>choice;
}
while(edit==1)
{
cout<<"需要添加事项月份: ";
cin>>m;
cout<<"输入日期: ";
cin>>n;
collect[m-1][n-1]=addition(m,n);
cout<<"添加成功!"<<endl;
cout<<"继续按【1】 ";
cout<<"返回按【4】 ";
cin>>edit;
cout<<endl;
if(edit!=1)
{
cout<<endl;
cout<<"1.添加事项按【1】"<<endl;
cout<<endl;
cout<<"2.编辑事项按【2】"<<endl;
cout<<endl;
cout<<"3.删除事项按【3】"<<endl;
cout<<endl;
cout<<"4.返回主菜单【4】"<<endl;
cin>>edit;
cout<<endl;
}
if(edit==4)
{
cout<<setw(40)<<"# 1.查询日历请按【1】 ";
cout<<"& 2.查询事项请按【2】 "<<endl;
cout<<endl;
cout<<endl;
cout<<setw(40)<<"* 3.编辑事项请按【3】 ";
cout<<"$ 4.退出系统请按【4】 "<<endl;
cin>>choice;
}
}
while(edit==2)
{
cout<<"需要修改事项月份: ";
cin>>m;
cout<<"需要修改事项日期: ";
cin>>n;
collect[m-1][n-1]=addition(m,n);
cout<<"继续按【1】 ";
cout<<"返回按【4】 ";
cin>>edit;
cout<<endl;
if(edit!=2)
{
cout<<endl;
cout<<"1.添加事项按【1】"<<endl;
cout<<endl;
cout<<"2.编辑事项按【2】"<<endl;
cout<<endl;
cout<<"3.删除事项按【3】"<<endl;
cout<<endl;
cout<<"4.返回主菜单【4】"<<endl;
cin>>edit;
cout<<endl;
}
if(edit==4)
{
cout<<setw(40)<<"# 1.查询日历请按【1】 ";
cout<<"& 2.查询事项请按【2】 "<<endl;
cout<<endl;
cout<<endl;
cout<<setw(40)<<"* 3.编辑事项请按【3】 ";
cout<<"$ 4.退出系统请按【4】 "<<endl;
cin>>choice;
}
}
while(edit==3)
{
cout<<"需要删除事项月份: ";
cin>>m;
cout<<"需要删除事项日期: ";
cin>>n;
h=&collect[m-1][n-1];
h->days=0;
h->months=0;
cout<<"删除成功!"<<endl;
cout<<"继续按【1】 ";
cout<<"返回按【4】 ";
cin>>edit;
cout<<endl;
if(edit!=3)
{
cout<<endl;
cout<<"1.添加事项按【1】"<<endl;
cout<<endl;
cout<<"2.编辑事项按【2】"<<endl;
cout<<endl;
cout<<"3.删除事项按【3】"<<endl;
cout<<endl;
cout<<"4.返回主菜单【4】"<<endl;
cin>>edit;
cout<<endl;
}
if(edit==4)
{
cout<<setw(40)<<"# 1.查询日历请按【1】 ";
cout<<"& 2.查询事项请按【2】 "<<endl;
cout<<endl;
cout<<endl;
cout<<setw(40)<<"* 3.编辑事项请按【3】 ";
cout<<"$ 4.退出系统请按【4】 "<<endl;
cin>>choice;
}
}
}
}
cout<<"--------------------------------------"<<endl;
cout<<"已经退出! 谢谢使用!!"<<endl;
return 0;
}
主界面:
查看日历:
添加信息:
查看某日信息:
查看全部:
修改信息:
删除信息:
退出系统: