tyzw.net
当前位置:首页 >> C语言问题,见补充代码和图片,输出这一年的第多少... >>

C语言问题,见补充代码和图片,输出这一年的第多少...

#include struct tian { int year; int month; int day; }; int days(int year,int month,int day) { int s=0,i,a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; if(year%4==0&&year%100!=0||year%400==0) a[2]=29; for(i=1;i

#include "stdio.h" #include "conio.h" main() { int day,month,year,sum,leap; printf("\nplease input year,month,day\n"); scanf("%d,%d,%d",&year,&month,&day); switch(month) /*先计算某月以前月份的总天数*/ { case 1:sum=0;break; case...

你对闰年的判断条件有点问题,而且找到一个闰年之后不能简单的4*(n-1)计算第N个,要老老实实继续往下找。代码实现如下: #includeint leap(int Y, int N){ int i=Y;while(1) {if (((i%4==0)&&(i%100!=0)) || (i%400==0)){N --;/* 找到一个闰年N...

#include void main(){int i,year,month,day,n=0,a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};scanf("%d/%d/%d",&year,&month,&day);if((year%4==0&&year%100)||year%400==0) a[2]=29;for(i=0;i

#include /* 此头函数请不要删除 */ #include int main() { int days[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int i,j,k,y,m,d,b,n,sum; while(scanf("%d/%d/%d",&y,&m,&d)!=EOF)/*日期输入格式:2010/6/9*/ { sum=0; for(i=1;i2) sum=sum+...

可以使用数组,并且使用数组代码更简洁一些,参考代码如下: #include int main(){ int i, days = 0; int year, month, day; int day_tab[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; printf("输入年、月、日,用空格隔开:");...

楼上的答案不对,输入2015,365却显示12月 28号

#include void main() { int y,m,d; int sum=0; int flog;//标识是否是闰年 printf("请输入年月日(yyyy-mm-dd)\n"); scanf("%4d-%2d-%2d",&y,&m,&d); if(( y%4==0 && y%100!=0 ) || y%400==0) flog=1; else flog=0; while((y12||m28))) { printf...

#include void main() { int year,month,day; int tempmonth,yearday; int week,weekday; unsigned int sum=0; int tag=0; printf("输入年、月、日:\n"); scanf("%d %d %d",&year,&month,&day); tag =( year - 1980 )/4; sum=(year-1984)*365 + ...

这个问题很简单,以下是我写的源代码,调试通过,你可以试试,写的很基础,应该能看懂,不懂追问! #include #include void Monthday(int year,int yearDay,int *pMonth,int *pDay) { int dec ; if((year%4 == 0 && year %100 != 0) || (year % ...

网站首页 | 网站地图
All rights reserved Powered by www.tyzw.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com