| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 678 人关注过本帖
标题:某年某月某日
只看楼主 加入收藏
牧人
Rank: 1
等 级:新手上路
帖 子:126
专家分:0
注 册:2008-10-22
结帖率:100%
收藏
 问题点数:0 回复次数:3 
某年某月某日
输入某年某月的某日,判断这天是改年的第多少天,
{要求用函数实现???}



急求!!!!!1111
搜索更多相关主题的帖子: 某年某月某日 
2008-10-30 15:12
smltq
Rank: 6Rank: 6
等 级:侠之大者
威 望:8
帖 子:566
专家分:400
注 册:2008-1-21
收藏
得分:0 
为什么不自己写呢

简单的生活
2008-10-30 16:50
牧人
Rank: 1
等 级:新手上路
帖 子:126
专家分:0
注 册:2008-10-22
收藏
得分:0 
会就不问了;
会就不请教了;
2008-10-30 22:01
hjmHhyp
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2008-10-9
收藏
得分:0 
这个程序是我自己写的,比较繁琐,但算法还是比较简单的,楼主可以在我的基础上加以改进。

#include "iostream.h"
#include "stdio.h"

#define COUNT  printf("It is error!\n")

int NoLeap_day(int year);
int Leap_day(int year);

struct date
{   
    int year;
    int months[2][13];
    int day;
}DATE;

void main()
{
    struct date DATE;
    struct date *p;
    p=&DATE;
    int Dayst;
    cin>>p->year;
    if((p->year%100!=0)&&(p->year%4==0)||(p->year%400==0))
    {
        Dayst=Leap_day(p->year);
    }
    else
    {
        Dayst=NoLeap_day(p->year);
    }
}

int Leap_day(int year)
{
    int i,month,day,Dayst,months[2][13]={{0,31,29,31,30,31,30,31,31,30,31,30,31},{0,31,28,31,30,31,30,31,31,30,31,30,31}};
    cin>>month>>day;
    Dayst=0;
    if(month<=12)
    {
    if(day>months[0][month])
    {
        return COUNT;
    }
    else
    {
    for(i=0;i<month;i++)
    {
        Dayst+=months[0][i];

    }
    Dayst+=day;
    return     printf("The day is the %d day.",Dayst);
    }
    }
    else return COUNT;
}

int NoLeap_day(int year)
{
int i,month,day,Dayst,months[2][13]={{0,31,29,31,30,31,30,31,31,30,31,30,31},{0,31,28,31,30,31,30,31,31,30,31,30,31}};
    cin>>month>>day;
    Dayst=0;
    if(month<=12)
    {
    if(day>months[0][month])
    {
        return COUNT;
    }
    else
    {
    for(i=0;i<month;i++)
    {
        Dayst+=months[1][i];
    }
    Dayst+=day;
    return     printf("The day is the %d day.",Dayst);
    }
    }
    else return COUNT;
}
2008-10-30 22:29
快速回复:某年某月某日
数据加载中...
 
   



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

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