标题:求某日是一年中的第几天 程序找错 运行不了
只看楼主
huaheshang
Rank: 2
来 自:日照
等 级:论坛游民
帖 子:91
专家分:37
注 册:2010-12-7
结帖率:79.31%
已结贴  问题点数:20 回复次数:2 
求某日是一年中的第几天 程序找错 运行不了
#include"stdio.h"
#include"math.h"
int leap(int year)
{
    if((year%4==0&&year%100!=0)||year%400==0)
     return 1;
    else
       return 0;
}
int days(int y,int m,int d)
{
    int i,j,sum=0,z;
     int ruun[12]={31,29,31,30,31,30,31,31,30,31,30,31};
     int ping[12]={31,28,31,30,31,30,31,31,30,31,30,31};
     z=leap(y);
    if(z==1)
     {


            for(i=0;i<m-1;i++)

                sum=sum+ruun[i];
            }


    else

{


          for(j=0;j<m-1;j++)

                sum=sum+ping[j];
            }
        sum=sum+d;

    return sum;
}
  main()
  {
      int days(int y,int m,int d)
      int year,month,day,n;
      printf("please input  year:month:day\n");
      scanf("%d%d%d,&year,&month,&day");
      getchar();
      n=days(year,month,day);
      printf("%d-%d-%d is the %d day of this year!,year,month,day,n");
      getchar();
  }
搜索更多相关主题的帖子: 运行 int year return sum 
2019-04-20 14:44
word123
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:13
帖 子:333
专家分:1622
注 册:2014-4-5
得分:20 
scanf("%d%d%d,&year,&month,&day");
=》scanf("%d%d%d",&year,&month,&day);

printf("%d-%d-%d is the %d day of this year!,year,month,day,n");
=>printf("%d-%d-%d is the %d day of this year!",year,month,day,n);
2019-04-20 15:13
huaheshang
Rank: 2
来 自:日照
等 级:论坛游民
帖 子:91
专家分:37
注 册:2010-12-7
得分:0 
谢谢,另外int days(int y,int m,int d)后忘加;。
2019-04-20 15:20



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




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

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