用c语言调用函数编程,1990年1月1日是星期一 要求输入某年某月某日,输出它是星期几

用c语言调用函数编程,1990年1月1日是星期一 要求输入某年某月某日,输出它是星期几

第1个回答  推荐于2017-11-21
这个是1984年1月1日是星期日的,你先看看,我再帮你改,最好自己能看懂
#include <stdio.h>
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 + tag;
tempmonth = month - 1;
yearday = 0;
switch(tempmonth)
{
case 12:yearday+=31;
case 11:yearday+=30;
case 10:yearday+=31;
case 9:yearday+=30;
case 8:yearday+=31;
case 7:yearday+=31;
case 6:yearday+=30;
case 5:yearday+=31;
case 4:yearday+=30;
case 3:yearday+=31;
case 2:yearday+=28;
case 1:yearday+=31;
}
yearday = yearday+day;

if ((year-1984)%4==0 && month > 2)
{
yearday+=1;
}
sum=sum+yearday;
if (year==1984)
{
sum-=1;
}
printf("距1984年1月1日一共有%d天\n",sum);
/*上面是计算输入的日期距1984年1月1日一共经历了多少天*/
weekday = (sum-1) % 7;
week = yearday / 7;
printf("今天是第%d个星期,星期%d",week,weekday);
return ;
}

下面是修改好的,能多给些分嘛?写程序不容易,还有,好好学习,这些不难,就是多花点时间而已
#include <stdio.h>
void main()
{
int year,month,day;
int tempmonth,yearday;
int week,weekday;
int sum=0;
int tag=0;
printf("输入年、月、日:\n");
scanf("%d %d %d",&year,&month,&day);
tag =( year - 1988 )/4;
printf("tag=%d\n",tag);
sum=(year-1990)*365 + tag;
tempmonth = month - 1;
yearday = 0;
switch(tempmonth)
{
case 12:yearday+=31;
case 11:yearday+=30;
case 10:yearday+=31;
case 9:yearday+=30;
case 8:yearday+=31;
case 7:yearday+=31;
case 6:yearday+=30;
case 5:yearday+=31;
case 4:yearday+=30;
case 3:yearday+=31;
case 2:yearday+=28;
case 1:yearday+=31;
}
yearday = yearday+day;

if ((year-1988)%4==0 && month > 2)
{
yearday+=1;
}
sum=sum+yearday;

printf("sum=%d\n",sum);
printf("距1990年1月1日一共有%d天\n",sum);
/*上面是计算输入的日期距1990年1月1日一共经历了多少天*/
weekday = (sum-1) % 7+1;
week = yearday / 7;
printf("今天是第%d个星期,星期%d",week,weekday);
return ;
}本回答被网友采纳

跪求一个c语言编写的日历程序(最好加上注释)
case 0:cout<<"星期日"<<endl;break; case 1:cout<<"星期一"<<endl;break; case 2:cout<<"星期二"<<endl;break; case 3:cout<<"星期三"<<endl;break; case 4:cout<<"星期四"<<endl;break; case 5:cout<<"星期五"<<endl;break; case 6:cout<<"星期六"<<endl;break; } cout<<year2<<...

数组c语言 输入某年某月某日 判断这一天是星期几
num=(y-1)+(y-1)\/4-(y-1)\/100+(y-1)\/400+n;printf("那天是星期%d\\n",num%7);\/\/星期0代表星期天 \/\/getch();}

C语言编程:输入某年某月某日判断这一天是一年的第几天的程序是是什么...
include \\x0d\\x0a\\x0d\\x0a\/\/返回指定年月日是对应年度的第几天\\x0d\\x0aint getDays(int month,int day);\\x0d\\x0aint isRunnian(int year);\\x0d\\x0a\\x0d\\x0aint main(int argc,char* argv[])\\x0d\\x0a{\\x0d\\x0aint year=0;\\x0d\\x0aint month=0;\\x0d\\x0a...

c++:某年某月某日是星期几
给你个C语言实现的版本:蔡勒公式计算星期几

输入某年某月某日,输出这是今年的第几天,C语言问题
mdays[1] = 29;\/\/设置闰年二月值。if(y<0 || m<=0 || m>12 || d<=0 || d>mdays[m-1])\/\/输入非法。{ printf("输入年月日不合法\\n");\/\/提示并退出。return -1;} for(i = 0; i < m-1; i ++)\/\/累加之前各个月。r+=mdays[i];r+=d;\/\/累加日期值。printf("%d\\n...

c语言编程:输入某年某月某日,计算出这一天是该年的第几天?该怎么解答啊...
\/\/输入年月日,输出是该年第几天 include<stdio.h> int sum(int month,int day){ int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};int i;for(i=1;i<month;i++)day+=days[i];return(day);} int leap(year){ int leap=0;if((year%4==0&&year%100!=0)||(...

c语言万年历程序,要求输入一个年份,打印出该年年历,要求三个月并排输出...
include<windows.h> int menu(){ char ch;int x;system("cls");printf("请选择相应的菜单:\\n");printf("***\\n");printf("查询某年某月某日是星期几,输入1回车:\\n");printf("查询某年是否是闰年,输入2回车:\\n");printf("打印某年的全年日历,输入3回车:\\n");printf("退出,输入0回车...

C语言编程:输入某年某月某日,判断这一天是这一年的第几天?
return c+d;}else{ return d;}}} void main(){ int y,m,d,count=1;printf("请输入年月日(例如2017-01-01):");scanf("%d-%d-%d",&y,&m,&d);while( (((y%4==0 && y%100!=0)||(y%400==0)) && (m==2)) && d>29) || (y%400!=0 && y%4!=0 && m==2...

c语言编程:编写程序,输入某年某月某日,判断这一天是这一年的第几天...
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,%d",&y,&m,&d);if (y%4==0&&y%100!=0||y...

c语言输入某年某月某日,求下一天的日期?
int day[12] = {31,28,31,30,31,30,31,31,30,31,30,31};printf("Please input year-month-day : ",year1,month1,day1);scanf("%d-%d-%d",&year1,&month1,&day1);if((year1 % 400 == 0) || (year1 % 4 == 0 && year1 % 100 != 0))day[1] = 29;if(month1 ...

相似回答