| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 568 人关注过本帖
标题: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
快速回复:please have a look
数据加载中...
 
   



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

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