回 帖 发 新 帖 刷新版面

主题:校历生成器 C语言

根据输入的开学和放假日期,为每学期生成相应的校历,并提供各学期的校历查询显示功能。
(1)输入数据
     学年度: 2007-2008
  学期:  2
  开学日期: 2008-02-18
  放假日期: 2008-07-05

(2)输出数据
       2007--2008 学年度 第 2 学期
 --------------------------------------------------------------------------------------------------
 月份 周次 一  二  三  四  五  六  日
 --------------------------------------------------------------------------------------------------
 二月 一  上课 19  20  21  22  23  24
 --------------------------------------------------------------------------------------------------
 二月 二  25  26  27  28  29  1  2
 --------------------------------------------------------------------------------------------------
 三月 三  3  4  5  6  7  8  9
 --------------------------------------------------------------------------------------------------
 三月 四  10  11  12  13  14  15  16
 --------------------------------------------------------------------------------------------------
 三月 五  17  18  19  20  21  22  23
 --------------------------------------------------------------------------------------------------
 三月 六  24  25  26  27  28  29  30
 --------------------------------------------------------------------------------------------------
 四月 七  31  1  2  3  4  5  6
 --------------------------------------------------------------------------------------------------
 四月 八  7  8  9  10  11  12  13
 --------------------------------------------------------------------------------------------------
 四月 九  14  15  16  17  18  19  20
 --------------------------------------------------------------------------------------------------
 四月 十  21  22  23  24  25  26  27
 --------------------------------------------------------------------------------------------------
 五月 十一 28  29  30  五一 2  3  4
 --------------------------------------------------------------------------------------------------
 五月 十二 5  6  7  8  9  10  11
 --------------------------------------------------------------------------------------------------
 五月 十三 12  13  14  15  16  17  18
 --------------------------------------------------------------------------------------------------
 五月 十四 19  20  21  22  23  24  25
 --------------------------------------------------------------------------------------------------
 五月 十五 26  27  28  29  30  31  1
 --------------------------------------------------------------------------------------------------
 六月 十六 2  3  4  5  6  7  8
 --------------------------------------------------------------------------------------------------
 六月 十七 9  10  11  12  13  14  15
 --------------------------------------------------------------------------------------------------
 六月 十八 16  17  18  19  20  21  22
 --------------------------------------------------------------------------------------------------
 六月 十九 复考 24  25  26  27  28  29
 --------------------------------------------------------------------------------------------------
 七月 二十 30  1  2  3  4  暑假 
 --------------------------------------------------------------------------------------------------
     
 要求:
 (1)界面布局美观
(2)节假日的计算和输出
 (3)闰年计算
 (4)年月日与周日的对应计算
 (5)年月日与周次的对应计算
 (6)周次与月份的对应计算
 (7)校历按文件保存
提示:
(1) 使用字符串、数组、文件
(2) 内存数据处理与界面输出分离

回复列表 (共10个回复)

沙发

#include<stdio.h>
#include <string.h>
void main ()
{
    int i,k,year,month1,day1,month2,day2,month;
     static int sum=1;
    int j=0;
    FILE *fp;
    printf("学年度:");
    scanf("%d %d",&year,&year);
    printf("学期:");
    scanf("%d",&i);
    printf("开学时间:");
    scanf("%d-%d-%d",&year,&month2,&day1);
    printf("放假时间:");
    scanf("%d-%d-%d",&year,&month1,&day2);
    printf("请输入要查询的月份:\n");
    scanf("%d",&month);
    

    switch(month)
    {
    case 2:  if((year%400==0)||(year%4==0))
                 {
                   printf("----------------------------------------------------------\n");
                   printf("月份 周次 一  二  三  四  五  六  日\n");
                   printf("%-3d",month);
                   printf("%5d",sum);
                  for(k=18;k<=29;k++)
                  {   ++j;
                   if(j%7==0)
                   {    printf("%4d",k);
                       printf("\n");
                       sum++;
                      printf("%-3d",month);
                      printf("%5d",sum);


                   }
                     else 
                     {  
                       printf("%4d",k);
                     }

                 }
                 printf("\n");

                 }
            else
            {
                   printf("----------------------------------------------------------\n");
                   printf("月份 周次 一  二  三  四  五  六  日\n");
                   printf("%-3d",month);
                   printf("%5d",sum);
                  for(k=18;k<=28;k++)
                  {   ++j;
                   if(j%7==0)
                   {    printf("%4d",k);
                       printf("\n");
                       sum++;
                      printf("%-3d",month);
                      printf("%5d",sum);


                   }
                     else 
                     {  
                       printf("%4d",k);
                     }

                 }
                 printf("\n");
                 printf("----------------------------------------------------------\n");
                break;

            }
    

板凳


case 3:
        {
                 printf("----------------------------------------------------------\n");
                   printf("月份 周次 一  二  三  四  五  六  日\n");
                   printf("%-3d",month);
                   printf("%5d",sum);
                  for(k=1;k<=31;k++)
                  {   ++j;
                   if(j%7==0)
                   {    printf("%4d",k);
                       printf("\n");
                       sum++;
                      printf("%-3d",month);
                      printf("%5d",sum);


                   }
                     else 
                     {  
                       printf("%4d",k);
                     }

                 }
                 printf("\n");
                 printf("----------------------------------------------------------\n");
                 break;
                  

        }
    case 4:
        {
                   printf("----------------------------------------------------------\n");
                   printf("月份 周次 一  二  三  四  五  六  日\n");
                   printf("%-3d",month);
                   printf("%5d",sum);
                  for(k=1;k<=30;k++)
                  {   ++j;
                   if(j%7==0)
                   {    printf("%4d",k);
                       printf("\n");
                       sum++;
                      printf("%-3d",month);
                      printf("%5d",sum);


                   }
                     else 
                     {  
                       printf("%4d",k);
                     }

                 }
                 printf("\n");
                 printf("----------------------------------------------------------\n");
                 break;

        }

3 楼


case 5:
        {
             printf("----------------------------------------------------------\n");
                   printf("月份 周次 一  二  三  四  五  六  日\n");
                   printf("%-3d",month);
                   printf("%5d",sum);
                  for(k=1;k<=31;k++)
                  {   ++j;
                   if(j%7==0)
                   {    printf("%4d",k);
                       printf("\n");
                       sum++;
                      printf("%-3d",month);
                      printf("%5d",sum);


                   }
                     else 
                     {  
                       printf("%4d",k);
                     }

                 }
                 printf("\n");
                 printf("----------------------------------------------------------\n");
                 break;

        }
    

4 楼

case 6:
        {
                printf("----------------------------------------------------------\n");
                   printf("月份 周次 一  二  三  四  五  六  日\n");
                   printf("%-3d",month);
                   printf("%5d",sum);
                  for(k=1;k<=30;k++)
                  {   ++j;
                   if(j%7==0)
                   {    printf("%4d",k);
                       printf("\n");
                       sum++;
                      printf("%-3d",month);
                      printf("%5d",sum);


                   }
                     else 
                     {  
                       printf("%4d",k);
                     }

                 }
                 printf("\n");
                 printf("----------------------------------------------------------\n");
                 break;

        }
    case 7:
        {
                 printf("----------------------------------------------------------\n");
                   printf("月份 周次 一  二  三  四  五  六  日\n");
                   printf("%-3d",month);
                   printf("%5d",sum);
                  for(k=1;k<=31;k++)
                  {   ++j;
                   if(j%7==0)
                   {    printf("%4d",k);
                       printf("\n");
                       sum++;
                      printf("%-3d",month);
                      printf("%5d",sum);


                   }
                     else 
                     {  
                       printf("%4d",k);
                     }

                 }
                 printf("\n");
                 printf("----------------------------------------------------------\n");
                 break;    
        }
        fp=fopen("stf","w");

    }
    

}

5 楼


这些是一起的。。。。一个程序的。

6 楼

这个,。其实很不错的.






















SIGNATURE:-------------------------------------------
Nothing is difficult for one who sets his mind to it.
[url=http://www.freeruntop.com/nike-free-run-2-men-c-50.html]nike free run 2[/url]

7 楼

可以学一学

8 楼

C语言学习群:149582523\144024225和220689612,欢迎大家来交流学习

9 楼

http://www.chengdubanzheng99.com/    
http://www.yangchengbzw.com/         
http://www.zhongxing999.com

10 楼

为你顶一下

我来回复

您尚未登录,请登录后再回复。点此登录或注册