ywtl.net
当前位置:首页>>关于用C语言编程:输入某年某月某日,判断这一天是这一年...的资料>>

用C语言编程:输入某年某月某日,判断这一天是这一年...

可以使用数组,并且使用数组代码更简洁一些,参考代码如下: #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("输入年、月、日,用空格隔开:");...

#include //返回指定年月日是对应年度的第几天 int getDays(int month,int day); int isRunnian(int year); int main(int argc,char* argv[]) { int year=0; int month=0; int day=0; printf("请输入年月日格式示例20140101\n"); sc...

参考代码如下: #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("输入年、月、日,用空格隔开:"); scanf("%d%d%d", &year, &month, &day); fo...

#include int main(){ int sum; int i,t,c; int month[12]={31,28,31,30,31,30,31,31,30,31,30,31}; int year,mon,day; printf("Please enter the times you want to calculate(eg.2):"); scanf("%d",&t); for(c=0;c

main() { int n,year,month,day,month_day_sum=0,sum, month_day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; printf("please input the \"year month day\"\n"); scanf("%d%d%d",&year,&month,&day); if(year%100!=0&&year%4==0||year%400) ...

#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 "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...

#include #include void main() { int y,m,d,sum1=0,sum2=0,i=0,sumok1=0,sumok2=0; int a1[]={31,29,31,30,31,30,31,31,30,31,30,31}; int a2[]={31,28,31,30,31,30,31,31,30,31,30,31}; printf("输入年月日(用逗号隔开):\n"); scanf("%d,%d,%...

额,你的判断闰年那里的条件错了。第二个闰年条件应该是被4整除,不被100整除的。所以应该写成这样if(year%400==0||(year%4==0&&year%100!=0))

首先 我估计你输入没写对 要按照scanf的格式写 即应该输入2014,12,31回车 这样运行我未出错 其次 你1 3 5 7 8 10 12应该是一月31天 你写了30 另外 闰年判断你写了2个%400 最后 你闰年判断里面 等于== 写成了=号 这样永远是闰年

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