rmml.net
当前位置:首页 >> 用C语言从键盘任意输入一个日期(年月日),输出第二... >>

用C语言从键盘任意输入一个日期(年月日),输出第二...

#include int main(){ int s[2][13]={0,31,28,31,30,31,30,31,31,30,31,30,31, 0,31,29,31,30,31,30,31,31,30,31,30,31,}; int year=0; int month=0; int day=0; int n,i,daytemp; int flag=0; int nyear=0,nmonth=0,nday=0; printf("输入年月日...

#include int monthsize(int year,int month) {int days;if(month == 2) {if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0)return 29;return 28;}switch(month) {case 1 :case 3 :case 5 :case 7 :case 8 :case 10 :case 12 :days = 31...

//输入年月日,再输入天数,求这些天之后的日期是多少 #include int main() { int s[2][13]={0,31,28,31,30,31,30,31,31,30,31,30,31, 0,31,29,31,30,31,30,31,31,30,31,30,31,}; int year=0; int month=0; int day=0; int n,i,daytemp; int flag=...

我大概给个思路,代码是现写的 没调试 先定义每个月的天数,2月按28天算 输入年月日后,根据年判断是否闰年(闰年加1天),再从1月加到当月的前一月,再加上日期就可以了 #include int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31}; main...

if(leap==1 && nian>3) // 这边的nian>3可能有问题 sum++; 看一下我的回答: http://zhidao.baidu.com/question/1861857968737067267

#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 int main () { int y, m, d, c, w; printf ("输入年 月 日(空格间隔):"); scanf ("%d %d %d", &y, &m, &d); if (m ==1 || m == 2) { //判断月份是否为1或2 y--; m += 12; } c = y / 100; y = y - c * 100; w...

#include int main(){ int day = 0; int y = 0; int m = 1; int d = 0; scanf("%d-%d-%d", &y, &m, &d); switch(m-1) //故意没有在case里加break { case 11: day += 30; case 10: day += 31; case 9: day += 30; case 8: day += 31; case 7: day...

原创,经过VC编译可以运行。 #include main() { int year,month,day,flag=0; m: printf("Please input year month day:"); scanf("%d%d%d",&year,&month,&day); if((year%4==0&&year%100!=0)||year%400==0) flag=1; if(month==2) { if((day==28&...

#include int main(void) { int year, month, day; int m[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; printf("Input year month day:"); scanf("%d%d%d", &year, &month, &day); if (year % 4 == 0 && year % 100 != 0 || year % 4...

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