| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 396 人关注过本帖
标题:谁来给我解决一下我写的这个日历
取消只看楼主 加入收藏
★☆
Rank: 2
来 自:北京
等 级:禁止访问
帖 子:23
专家分:11
注 册:2009-10-16
结帖率:100%
收藏
 问题点数:0 回复次数:1 
谁来给我解决一下我写的这个日历
1.这个日历打印年不能全看见,只能看到后几个月
2.选择2打印月,打印完毕时输入w就会出现输入Day输入完day后怎么什么都读不出来,主要就是帮我解决一下记事的这个功能。谢谢
#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;
notebook(long date)
{

char note[1000];
FILE*fp;
fp=fopen;
if((fp=fopen("d:\\notebook.txt","a+"))==NULL)
{puts("This file can not be opened");exit(0);}
fscanf(fp,"%8s%s",date,&note);
fprintf(fp,"%8s%s",date,note);
fclose(fp);
if((fp=fopen("d:\\notebook.txt","r"))==NULL)
{gets("This input file can not be opened");exit(0);}
fscanf(fp,"%8s%s",date,&note);
fprintf(stdout," %8s   %s",date,note);
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");


}

main()
{


    int month,year,day,date;
    char menu;
    date=year*10000+month*100+day;
    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);
                        notebook(date);
                    }
                    else
                    return;
                break;
            case'3':
                return;
                break;

        }
    }
}
搜索更多相关主题的帖子: 日历 
2009-10-20 22:17
★☆
Rank: 2
来 自:北京
等 级:禁止访问
帖 子:23
专家分:11
注 册:2009-10-16
收藏
得分:0 
没有会的还是,懒的读啊,求求帮忙改下这个就可以
notebook(long date)
{
 
char note[1000];
FILE*fp;
fp=fopen;
if((fp=fopen("d:\\notebook.txt","a+"))==NULL)
{puts("This file can not be opened");exit(0);}
fscanf(fp,"%8s%s",date,&note);
fprintf(fp,"%8s%s",date,note);
fclose(fp);
if((fp=fopen("d:\\notebook.txt","r"))==NULL)
{gets("This input file can not be opened");exit(0);}
fscanf(fp,"%8s%s",date,&note);
fprintf(stdout," %8s   %s",date,note);
fclose(fp);
 
}

多多指教
2009-10-20 22:39
快速回复:谁来给我解决一下我写的这个日历
数据加载中...
 
   



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

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