标题:please have a look
只看楼主
aoyun2008
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-4-3
 问题点数:0 回复次数:0 
please have a look
#include<iostream.h>


    wannianli();
    int getweek(int year);
    int leapyear(int year);
    void getdays(int year,int *p,int n);
    
    void main()
{
    int year;
    cin>>year;
    int a[12]={31,29,30,31,30,31,31,30,31,30,31};
    int b[12]={31,28,30,31,30,31,31,30,31,30,31};
    
     int e=leapyear(year);
     if(e==1)
         getdays(year,a,12);
     else
         getdays(year,b,12);
}


int getweek(int year)
{
    int m;
    m=(year+(year-1)/4-(year-1)/100+(year-1)/400)%7;
    return m;
}

void  getdays(int year,int *p,int n)
{cout<<"一"<<" "<<"二"<<" "<<"三"<<" "<<"四"<<" "<<"五"<<" "<<"六"<<" "<<"日"<<endl;
    int count=0;
    for( int   i=1;i<getweek( year);i++)
    {
        
        cout<<" "<<" ";
        count++;
    }
    for(  i=0;i<=11;i++)
    {
        for(int j=1;j<=p[i];j++)
        {
            cout<<j<<" ";
            count++;
            if(count%7==0)
                cout<<endl;
            else
                continue;
        }
        cout<<endl;
        
        for(int k=1;k<=(count%7);i++)
        {cout<<" "<<" ";
        count++;
        }
    }
}
int leapyear(int year)
{
    if((year%400==0)||((year%100!=0)&&(year%4==0)))
        return 1;
    else
        return 0;
}
运行的时候怎么只出现两个或三个月份的日历?
搜索更多相关主题的帖子: look please 
2008-04-25 10:05



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-210965-1-1.html




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

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