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

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

//输入年月日,再输入天数,求这些天之后的日期是多少 #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=...

#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 void main() { int i,year,month,day,d=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 #includestruct date{int year, mouth, day;};int main(){struct date d;int i, k=0, nday=0;printf("请输入当前年月日: ");scanf("%d%d%d", &d.year, &d.mouth, &d.day);///先判断是否是闰年,符合条件就是闰年,k置为1if(d.year%4==0 ...

#include void main(){ int year, month, day, curyear, curmonth, curday; printf ("输入年月日:\n"); scanf ("%d/%d/%d", &year, &month, &day); curyear = year; curmonth = month; curday = day; while (year!=0 || month!=0 || day!=0) { ...

#include "stdio.h" int main(){ int a,b; printf("请输入年份和月份"); scanf("%f%f",&a,&b); if ("a%4==0&&b==02"){ printf("这个月有29天"); } else (b==02){ printf("这个月有28天"); } if ("a%4=!0&&b==01||b==03||b==05||b==07||b==08||b=...

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