QQ网名大全

万年历(c语言编程)

#include<stdio.h>
#include<time.h>
int leap (int year)//判断闰年
{
if(year%4==0&&year%100!=0||year%400==0)
return 1;
else return 0;
}
int days_month (int month,int year)//判断月
{
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
return 31;
if(month==4||month==6||month==9||month==11)
return 30;
if(month==2&&leap(year)==1) return 29;
else return 28;
}
int firstday(int month,int year)//判断年
{
int w;
w=(1+2*month+3*(month+1)/5+year+year/4+year/400-year/100)%7+1;
return w;
}
main()
{
//调用系统时间
time_t tval;
struct tm *now;
tval = time(**);
now = localtime(&tval);
printf("现在时间: %4d年 %d月 %02d日 %d:%02d:%02d\n", now->tm_year+1900, now->tm_mon+1, now->tm_mday,
now->tm_hour, now->tm_min, now->tm_sec);
//调用结束

int i,j=1,k=1,a,b,month,year;
b=days_month(now->tm_mon+1,now->tm_year+1900);
a=firstday (now->tm_mon+1,now->tm_year+1900);
printf(" sun mon tue wed thu fri sat \n");
if(a==7)
{
for(i=1;i<=b;i++)
{
printf("%4d",i);
if(i%7==0)
{
printf("\n");
}
}
}
if(a!=7)
{
while (j<=4*a)
{
printf(" ");
j++;
}
for(i=1;i<=b;i++)
{
printf("%4d",i);
if(i==7*k-a)
{
printf("\n");
k++;
}
}
}
printf("\n");
}
佚名
2024-05-30 04:56:52
最佳回答
类似问题(10)
  • 佚名
    2024-05-30 15:07:35

    c语言设计万年历

    看看没人帮你,我来帮你吧,以下是我新写的,用了我自己原创的算法,完全不同于网上的程序,等于说是专门为你量身定制的。奉上程序:#include <stdio...

  • 佚名
    2024-05-30 07:04:21

    万年历查询程序. c语言代码

    除了天数差计算,基本上是完成了你所提出的功能(天数差计算其实已经提供了年内序数计算方方法,可以在此基础上完善即可)。包含星期计算、公历转农历、农历转公历、节气查...

  • 佚名
    2024-05-30 08:00:00

    c语言编程

    设银行定期存款的年利率rate为2.25%,并已知存款期为n年,存款本金为capital元,试编程计算n年后的本利之和deposit。要求定期存款的年利率rat...

  • 佚名
    2024-05-30 08:00:00

    c语言编写万年历

    #include"stdio.h" #include"stdlib.h" #include"windows.h" void welcome(); void ge...

  • 佚名
    2024-05-30 08:00:00

    用c语言怎么编写万年历

    c语言编写万年历的源代码如下:#include <stdio.h>int week(int y,int m,int d);int main(){char ...

  • 佚名
    2024-05-30 08:00:00

    用c语言写万年历

    写万年历程序,您需要先了解万年历的特点 下面是万年历的特点(复制粘贴的):1. 平年365天(52周+1天),闰年366天(52周+2天)。平年2月28天,闰年...

  • 佚名
    2024-05-30 08:00:00

    关于万年历的c语言编程 第一次编这种大程序 不怎么懂 望有高手教教

    大哥你大几了?貌似这个不难吧。。注意一下格式的输出应该就很ok了

  • 佚名
    2024-05-30 08:00:00

    急!!!用c语言编写万年历!!!!!!!!!

    #include <stdio.h>#include <string.h>#include <ctype.h>long year;int mo...

  • 佚名
    2024-05-30 08:00:00

    用c++编写万年历程序

    指的是农历还是直接新历就可以了? 如果是新历,可以看我的老贴:http://最下面有样板,可以看一下。

  • 佚名
    2024-05-30 08:00:00

    c语言编程关机代码

    #include<stdio.h> #include<dos.h> void main( void ) { union regs in,out; i...