| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 384 人关注过本帖
标题:日历20091016
只看楼主 加入收藏
★☆
Rank: 2
来 自:北京
等 级:禁止访问
帖 子:23
专家分:11
注 册:2009-10-16
结帖率:100%
收藏
 问题点数:0 回复次数:1 
日历20091016
1.查询年历
2.查询月历
功能还未健全,期待评论
#include<stdio.h>
#include "conio.h"
#include<stdlib.h>
#include <conio.h>
int   e[]   =   {0,3,3,6,1,4,6,2,5,0,3,5};
char flag;








note(int year,int month,int day)
{
long char write;
FILE *fp;
if((fp=fopen("Notebook.txt","w"))==NULL)
{
    puts("\n\nThis file can not be opened");exit(0);
}
fscanf(stdin,"%s",&write);
fprintf(fp,"\n%d-%d-%d\n%s",year,month,day,write);
fclose(fp);


if((fp=fopen("NOTEBOOK.txt","r"))==NULL)
{
    puts("The input file can not be opened");exit(0);
}
fscanf(fp,"%d%d%d%s",year,month,day,&write);
fprintf(stdout,"\n%d-%d-%d\n%s",year,month,day,write);
fclose(fp);










}








print(int year,int month)
{
    int i, j;
    printf("MON\tTUE\tWEB\tTHU\tFRI\tSAT\t\SUN\n");
    if(month==2)
    {
       if (year%4==0&&year%100!=0||year%100==0)
       {

            for(i=1;i<=29;i++)
            {
                int rest=(i-1+e[month-1]+year+(year/4)-year/100+year/400);
                  --rest;
                  rest%=7;
                     if(i==1)                   /* 确定1号打印的位置 */
                     {
                        if(rest==0)              /*判断1号是否为星期日*/
                        {
                            printf("\t\t\t\t\t\t");
                        }
                        else
                        {

                            for(j=1;j<(rest%7);j++)
                            {
                                printf("\t");
                            }
                        }
                     }
                printf("%d\t",i);
                if(rest%7==0)
                printf("\n");
            }

        }
        else
        {



            for(i=1;i<=28;i++)
            {
                int rest=(i-1+e[month-1]+year+(year/4)-year/100+year/400);
                rest%=7;
                if(i==1)                      /* 确定1号打印的位置 */
                {
                    if(rest==0)                 /*判断1号是否为星期日*/
                    {
                        printf("\t\t\t\t\t\t");
                    }
                    else
                    {
                        for(j=1;j<(rest%7);j++)
                        {
                            printf("\t");
                        }
                    }
                }
                printf("%d\t",i);
                if(rest%7==0)
                printf("\n");
            }
        }

    }
    else
    {
        if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
        {
            for(i=1;i<=31;i++)
            {
                int rest=(i-1+e[month-1]+year+(year/4)-year/100+year/400);
                rest%=7;
                if(i==1)                   /* 确定1号打印的位置 */
                {
                    if(rest==0)             /*判断1号是否为星期日*/
                    {
                        printf("\t\t\t\t\t\t");
                    }
                    else
                    {
                        for(j=1;j<(rest%7);j++)
                        {
                            printf("\t");
                        }
                    }
                 }
                 printf("%d\t",i);
                 if(rest%7==0)
                 printf("\n");
            }
         }
         else
         {
            for(i=1;i<=30;i++)
            {

                int rest=(i-1+e[month-1]+year+(year/4)-year/100+year/400);
                rest%=7;
                if(i==1)                   /* 确定1号打印的位置 */
                {
                    if(rest==0)              /*判断1号是否为星期日*/
                    {
                        printf("\t\t\t\t\t\t");
                    }
                    else
                    {
                        for(j=1;j<(rest%7);j++)
                        {
                            printf("\t");
                        }
                    }
                 }
                 printf("%d\t",i);
                 if(rest%7==0)
                 printf("\n");
            }
         }
    }
    printf("\n");


}
notebook(int year,int month,int day)
{












}
main()
{


    int month,year,day;
    char menu;
    menu:
        system("cls");
        clreol();
        printf("\n\t\t\t******************************\n");
        printf("\t\t\t*\t      Menu           *\n");
        printf("\t\t\t*\t1.Year Calender      *\n");
        printf("\t\t\t*\t2.Month Calender     *\n");
      /*  printf("\t\t\t*\t3.Note Book          *\n");     */
        printf("\t\t\t*\t3.Exit               *\n");
        printf("\t\t\t******************************\n");
        printf("\t\t\t*   please enter selection   *\n");
        printf("\t\t\t******************************\n");
        gotoxy(51,8);
    while(1)
    {
        menu=getch();
        switch(menu)
        {      
            case'1':
                system("cls");
                clreol();
                printf("\n\t\t\t******************************\n");
                printf("\t\t\t*\t      Menu           *\n");
                printf("\t\t\t*\t1.Year Calender      *\n");
                printf("\t\t\t*\t2.Month Calender     *\n");
              /*  printf("\t\t\t*\t3.Note Book          *\n");    */
                printf("\t\t\t*\t3.Exit               *\n");
                printf("\t\t\t******************************\n");
                printf("\t\t\t*\t     year:           *\n");
                printf("\t\t\t******************************\n");
                gotoxy(43,8);
                scanf("%d",&year);
                nextyear:
                if(flag=='n'||flag=='N')
                {
                year+=1;

                }
                previousyear:
                if(flag=='p'||flag=='P')
                {
                year-=1;

                }
                system("cls");
                clreol();
                for(month=1;month<13;month++)
                {

                    printf("\t\t\tYear: %d\tMonth:%d\n",year,month);
                    print(year,month);
                }
                printf("Press M to Menu N to Nextyear P to Previousyear.\nAnykey to Exit!\n");
                flag=getch();
                if(flag=='m'||flag=='M')
                {
                    goto menu;
                }
                else if(flag=='n'||flag=='N')
                {
                    goto nextyear;
                }
                else if(flag=='p'||flag=='P')
                {
                    goto previousyear;
                }
                else
                return;
                break;
            case'2':
                loop:
                    system("cls");
                    clreol();
                    printf("\n\t\t\t******************************\n");
                    printf("\t\t\t*\t      Menu           *\n");
                    printf("\t\t\t*\t1.Year Calender      *\n");
                    printf("\t\t\t*\t2.Month Calender     *\n");
                  /*  printf("\t\t\t*\t3.Note Book          *\n"); */
                    printf("\t\t\t*\t3.Exit               *\n");
                    printf("\t\t\t******************************\n");
                    printf("\t\t\t*   Year:\tMonth:       *\n");
                    printf("\t\t\t******************************\n");
                    gotoxy(34, 8);
                    scanf("%d",&year);
                    gotoxy(47, 8);
                    scanf("%d",&month);
                nextmonth:
                    if(month>12)
                    {   
                        month=1;
                        year+=1;
                    }
                previous:
                    if(month<1)
                    {
                        month=12;
                        year-=1;
                    }
                system("cls");
                clreol();
                printf("\n\t\t\t******************************\n");
                printf("\t\t\t*\t      Menu           *\n");
                printf("\t\t\t*\t1.Year Calender      *\n");
                printf("\t\t\t*\t2.Month Calender     *\n");
             /*   printf("\t\t\t*\t3.Note Book          *\n");    */
                printf("\t\t\t*\t3.Exit               *\n");
                printf("\t\t\t******************************\n");
                printf("\t\t\t*   Year:%d\tMonth:%d     *\n",year,month);
                printf("\t\t\t******************************\n");
                print(year,month);
                printf("\nPress M to Menu Space to Continue N to Nextmonth P to Previousmonth.\nAnykey to Exit!\n");
                flag=getch();
                    if(flag==' ')
                    {
                        goto loop;
                    }
                    else if(flag=='n'||flag=='N')
                    {
                        year=year;
                        month+=1;
                        goto nextmonth;
                    }
                    else if(flag=='p'||flag=='P')
                    {
                        year=year;
                        month-=1;
                        goto previous;
                    }
                    else if(flag=='m'||flag=='M')
                    {   
                        goto menu;
                    }
                    else if(flag=='w'||flag=='W')
                    {
                        system("cls");
                        clreol();
                        printf("\n\t\t\t******************************\n");
                        printf("\t\t\t*\t      Menu           *\n");
                        printf("\t\t\t*\t1.Year Calender      *\n");
                        printf("\t\t\t*\t2.Month Calender     *\n");
             /*         printf("\t\t\t*\t3.Note Book          *\n");    */
                        printf("\t\t\t*\t3.Exit               *\n");
                        printf("\t\t\t******************************\n");
                        printf("\t\t\t*\t     Day:            *\n");
                        printf("\t\t\t******************************\n");
                        gotoxy(42,8);
                        fscanf(stdin,"%d",&day);
                        note(year,month,day);
                    }
                    else
                    return;
                break;
            case'3':
                return;
                break;

        }
    }
}
CALENDER.rar (10.14 KB)
搜索更多相关主题的帖子: 日历 
2009-10-16 23:26
pgy
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:C
等 级:小飞侠
威 望:8
帖 子:1248
专家分:2329
注 册:2009-9-23
收藏
得分:0 
有些东西不是实际需要只需分析算法就可以了。
ps:楼主辛苦了
“为人民服务”(咦?这谁喊的?

我可好玩啦...不信你玩玩^_^
2009-10-17 00:04
快速回复:日历20091016
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.058472 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved