| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 945 人关注过本帖
标题:数学高手进来帮帮忙看看完善下这个码吧@_@!
取消只看楼主 加入收藏
gzliujie5
Rank: 1
来 自:贵州
等 级:新手上路
帖 子:22
专家分:5
注 册:2011-8-13
结帖率:66.67%
收藏
已结贴  问题点数:10 回复次数:5 
数学高手进来帮帮忙看看完善下这个码吧@_@!
#include "iostream.h"
int main()
{
    int a,b,c;
    char aper,count;
    cout<<"输入日期(如:2005-2-8):";
    cin>>a>>aper>>b>>count>>c;
    cout<<a<<aper<<b<<count<<c<<endl;
    switch ((a+3)/4-a/4&&(a/400+3)-a/400&&(a+399)/400-a/400)
    {
    case 0:
        if(b==1&&c&&c<=31) cout<<a<<"年"<<b<<"月"<<c<<"日是闰年"<<a<<"年的第"<<c<<"天!"<<endl;
        else
        {
            if(b==2&&c<=29) cout<<a<<"年"<<b<<"月"<<c<<"日是闰年"<<a<<"年的第"<<c+31<<"天!"<<endl;
            else
            {
                if(b==3&&c<=31) cout<<a<<"年"<<b<<"月"<<c<<"日是闰年"<<a<<"年的第"<<c+60<<"天!"<<endl;
                else
                {
                    if(b==4&&c<=30) cout<<a<<"年"<<b<<"月"<<c<<"日是闰年"<<a<<"年的第"<<c+91<<"天!"<<endl;
                    else
                    {
                        if(b==5&&c<=31) cout<<a<<"年"<<b<<"月"<<c<<"日是闰年"<<a<<"年的第"<<c+121<<"天!"<<endl;
                        else
                        {
                            if(b==6&&c<=30) cout<<a<<"年"<<b<<"月"<<c<<"日是闰年"<<a<<"年的第"<<c+152<<"天!"<<endl;
                            else
                            {
                                if(b==7&&c<=31) cout<<a<<"年"<<b<<"月"<<c<<"日是闰年"<<a<<"年的第"<<c+182<<"天!"<<endl;
                                else
                                {
                                    if(b==8&&c<=31) cout<<a<<"年"<<b<<"月"<<c<<"日是闰年"<<a<<"年的第"<<c+213<<"天!"<<endl;
                                    else
                                    {
                                        if(b==9&&c<=30) cout<<a<<"年"<<b<<"月"<<c<<"日是闰年"<<a<<"年的第"<<c+244<<"天!"<<endl;
                                        else
                                        {
                                            if(b==10&&c<=31) cout<<a<<"年"<<b<<"月"<<c<<"日是闰年"<<a<<"年的第"<<c+274<<"天!"<<endl;
                                            else
                                            {
                                                if(b==11&&c<=30) cout<<a<<"年"<<b<<"月"<<c<<"日是闰年"<<a<<"年的第"<<c+305<<"天!"<<endl;
                                                else
                                                {
                                                    if(b==12&&c<=31) cout<<a<<"年"<<b<<"月"<<c<<"日是闰年"<<a<<"年的第"<<c+335<<"天!"<<endl;
                                                    else cout<<"错误日期!"<<endl;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        break;
    case 1:
        if(b==1&&c<=31) cout<<a<<"年"<<b<<"月"<<c<<"日是平年"<<a<<"年的第"<<c<<"天!"<<endl;
        else
        {
            if(b==2&&c<=28) cout<<a<<"年"<<b<<"月"<<c<<"日是平年"<<a<<"年的第"<<c+31<<"天!"<<endl;
            else
            {
                if(b==3&&c<=31) cout<<a<<"年"<<b<<"月"<<c<<"日是平年"<<a<<"年的第"<<c+59<<"天!"<<endl;
                else
                {
                    if(b==4&&c<=30) cout<<a<<"年"<<b<<"月"<<c<<"日是平年"<<a<<"年的第"<<c+90<<"天!"<<endl;
                    else
                    {
                        if(b==5&&c<=31) cout<<a<<"年"<<b<<"月"<<c<<"日是平年"<<a<<"年的第"<<c+120<<"天!"<<endl;
                        else
                        {
                            if(b==6&&c<=30) cout<<a<<"年"<<b<<"月"<<c<<"日是平年"<<a<<"年的第"<<c+151<<"天!"<<endl;
                            else
                            {
                                if(b==7&&c<=31) cout<<a<<"年"<<b<<"月"<<c<<"日是平年"<<a<<"年的第"<<c+181<<"天!"<<endl;
                                else
                                {
                                    if(b==8&&c<=31) cout<<a<<"年"<<b<<"月"<<c<<"日是平年"<<a<<"年的第"<<c+212<<"天!"<<endl;
                                    else
                                    {
                                        if(b==9&&c<=30) cout<<a<<"年"<<b<<"月"<<c<<"日是平年"<<a<<"年的第"<<c+243<<"天!"<<endl;
                                        else
                                        {
                                            if(b==10&&c<=31) cout<<a<<"年"<<b<<"月"<<c<<"日是平年"<<a<<"年的第"<<c+273<<"天!"<<endl;
                                            else
                                            {
                                                if(b==11&&c<=30) cout<<a<<"年"<<b<<"月"<<c<<"日是平年"<<a<<"年的第"<<c+304<<"天!"<<endl;
                                                else
                                                {
                                                    if(b==12&&c<=31) cout<<a<<"年"<<b<<"月"<<c<<"日是平年"<<a<<"年的第"<<c+334<<"天!"<<endl;
                                                    else cout<<"错误日期!"<<endl;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        break;
    }
    return 0;
}
搜索更多相关主题的帖子: 400 include count 数学 
2011-08-13 12:16
gzliujie5
Rank: 1
来 自:贵州
等 级:新手上路
帖 子:22
专家分:5
注 册:2011-8-13
收藏
得分:0 
有兴趣的帮忙看下,这个码还有很多错误的运算,但是我数学不是很厉害,公式实在不知道杂用了,高手帮忙指点下。
能够帮忙简化和校正,感激不尽啊。
2011-08-13 12:18
gzliujie5
Rank: 1
来 自:贵州
等 级:新手上路
帖 子:22
专家分:5
注 册:2011-8-13
收藏
得分:0 
回复 5楼 loveshuang
if(a%400==0||a%4==0&&a%100!=0)
这个高手,这个可以解释解释么~~~你的码没有备注,我看得不是很懂,刚学没几天呢~~~
2011-08-13 16:53
gzliujie5
Rank: 1
来 自:贵州
等 级:新手上路
帖 子:22
专家分:5
注 册:2011-8-13
收藏
得分:0 
呵呵,看懂了,谢谢啊,谢谢了,%是整除,我以为是除了之后可以有小数,如10%3=3.33333...看来我误会了,呵呵。只知道10/3=3.呵呵
十分感谢!

再问个问题~~~  -=是什么意思?sum-=31;   解释下,这个代码我就全懂咯。
2011-08-13 18:47
gzliujie5
Rank: 1
来 自:贵州
等 级:新手上路
帖 子:22
专家分:5
注 册:2011-8-13
收藏
得分:0 
回复 8楼 loveshuang
呵呵,看懂了,谢谢啊,谢谢了,%是整除,我以为是除了之后可以有小数,如10%3=3.33333...看来我误会了,呵呵。只知道10/3=3.呵呵
十分感谢!

再问个问题~~~  -=是什么意思?sum-=31;   解释下,这个代码我就全懂咯。

再帮忙解释解释,呵呵,感激不尽啊,嘿嘿。
2011-08-13 18:49
gzliujie5
Rank: 1
来 自:贵州
等 级:新手上路
帖 子:22
专家分:5
注 册:2011-8-13
收藏
得分:0 
回复 13楼 qchi
呵呵,因为我刚学,还不会简化程序。
2011-08-14 10:13
快速回复:数学高手进来帮帮忙看看完善下这个码吧@_@!
数据加载中...
 
   



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

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