| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 381 人关注过本帖
标题:万年历的输出谁看的懂,帮忙解释一下,谢谢
只看楼主 加入收藏
爱追求
Rank: 2
等 级:论坛游民
帖 子:9
专家分:23
注 册:2013-10-18
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:2 
万年历的输出谁看的懂,帮忙解释一下,谢谢
void OutPut(float days,int year,int month)
{
    int i,k=0,n;
    printf("日\t一\t二\t三\t四\t五\t六\t\n");
    printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
    k=(int)days%7;
    if(k!=6)//表示第一行开头需要k+1个空 (为什么?)
    {
        for(i=0;i<k+1;i++)
            printf(" \t");
    }
    k=k+1;//调整k值,用于接下来的输出计数
    n=Distinguish(year,month);
    for(i=1;i<=n;i++)
    {
        printf("%d\t",i);
        if(k%7==6)//每行7个
        {
            printf("\n");
            printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");

        }
        k=k+1;
    }
    printf("\n");
}
搜索更多相关主题的帖子: 万年历 
2013-12-02 22:51
℃Buffer
Rank: 2
等 级:论坛游民
帖 子:25
专家分:48
注 册:2013-2-26
收藏
得分:20 
#include<stdio.h>
void screen();
void whatisit();
void leapyear();
void printyearday();
int IsLeapYear(int);
int whatisita(int,int);
int everymonth(int,int);
void printmonth(int,int);
void printmonthday();
/******************************************************************/
char *week[]={"Sunday","Monday","Tuesday","Wednesday","Thurday","Friday","Saturday"};
void main()
{
    int n;
    while(1)
    {
       printf("万年历查询程序:\n");
       printf("1.查询某年某月某日是星期几\n");
       printf("2.查询某年是否是闰年\n");
       printf("3.打印某年的全年的日历\n");
       printf("4.查询某月的最大天数\n");
       printf("5.退出\n");
       printf("请输入要查询的选项:");
       scanf("%d",&n);
       switch(n)
       {
         case 1:whatisit();break;
         case 2:leapyear();break;
         case 3:printyearday();break;
         case 4:printmonthday();break;
         case 5:return;
         default:printf("你输入错误,请按要求输入!!!\n");break;
       }
    }
}
void whatisit()
{
    int y,m,d,s,k=1,sum,n,i;
    char yn;
    int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    while(k)
    {
        printf("请依次输入年,月,日:\n");
        scanf("%d,%d,%d",&y,&m,&d);
        s=0;
        for(i=1;i<m;i++)
            s=s+a[i];
        s=s+d;
        if(IsLeapYear(y)&&m>2)s=s+1;
        sum=s;
        n=(y-2+(y+1)/4-(y-1)/100+(y-1)/400+sum)%7;//
        printf("这天是%s\n",week[n]);
        printf("是否继续查询(Y/N)?");
        scanf("%c",&yn);getchar();
        if(yn=='y'||yn=='y')k=1;
        else k=0;
    }
}
/**********************************************/
int IsLeapYear(int year)
{
    return(year%4==0 &&year%100!=0)||(year%400==0);}
/************************************************/
void leapyear()
{int y,k=1;
char yn;
while(k)
{
    printf("请输入要查询的年份:\n");
    scanf("%d",&y);
    if(IsLeapYear(y))
        printf("是闰年!\n");
    else
        printf("不是闰年!\n");
    printf("是否继续查询(Y/n)?");
    scanf("%c",&yn);
    getchar();
    if(yn=='y'||yn=='Y')k=1;
    else k=0;
}
}
/***********************************************************/
int whatisita(int y,int m)
{
    int n,i;
    int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},s=0;
    for(i=1;i<m;i++)
    s=s+a[i];
    if(IsLeapYear(y)&&m>2)s=s+1;
    n=(y-1+(y+1)/4-(y-1)/100+(y-1)/400+s+1)%7;
    return n;
}
/******************************************************/
void printyearday()
{
    int y,value,sum,i,k=1;char yn;
    while(k)
    {
        printf("请输入查询日立的年份\n:");
        scanf("%d",&y);
        for(i=1;i<=12;i++)
        {
            printf("%d年%d月的信息:\n",y,i);
            value=whatisita(y,i);
            sum=everymonth(value,sum);
            printf("\n");
        }
        printf("是否继续查询(Y/N)?");
        scanf("%c",&yn);getchar();
        if(yn=='y'||yn=='Y')k=1;
        else k=0;
    }
}
/******************************************************/
int everymonth(int year,int month)
{
    int s;
    static int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    s=a[month];
    if(IsLeapYear(year)&&month==2)
        s=s+1;
    return s;
}
/***************************************************/
void printmonthday()
{
    int y,m,value,k=1;char yn;
    while(k)
    {
        printf("请输入查询的年份,月份\n:");
        scanf("%d,%d",&y,&m);
        value=everymonth(y,m);
        printf("%d年%d月的最大天数为%d:\n",y,m,value);
        printf("是否继续查询(Y/N)?");
        scanf("%c",&yn);getchar();
        if(yn=='y'||yn=='Y')k=1;
        else k=0;
    }
}
void printmmonth(int value,int sum)
{
    int n,i=0,j;
    char *x[7]={"Sunday","Monday","Tuesday","Wednesday","Thurday","Friday","Saturday"};//
    for(j=0;j<7;j++)
    {
        printf("%s",x[j]);
    }
    printf("\n");
    while(i<value){printf("");i++;}
    for(n=1;n<7-value;n++)
        printf("   %d",n);
    while(n<sum)
    {
        if((n+value-1)%7==0)
            printf("\n");
        if(n/10>0)
            printf("   %d",n);
        else
            printf("   %d",n);
        n++;
    }
}
2013-12-02 23:30
爱追求
Rank: 2
等 级:论坛游民
帖 子:9
专家分:23
注 册:2013-10-18
收藏
得分:0 
回复 2楼 ℃Buffer
谢谢,我一定会好好看向你学习
2013-12-02 23:35
快速回复:万年历的输出谁看的懂,帮忙解释一下,谢谢
数据加载中...
 
   



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

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