万年历(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");
}
#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...
风水
起名
网名
- 1 马甲线网名
- 2 关于星座的情侣网名
- 3 昵称边框
- 4 微信昵称夏微凉
- 5 用容字微信昵称
- 6 昵称双下巴
- 7 医学相关的昵称
- 8 男孩说瓜皮是昵称
- 9 微信改昵称最长几个字
- 10 给支付宝取个昵称大全
说说
- 1 2014qq个性签名超拽
- 2 怎样写说说有个性签名
- 3 2018qq改不了个性签名
- 4 女生旅游签名
- 5 男生繁体字签名
- 6 母亲节对母亲的说说
- 7 和朋友摘草莓开心说说
- 8 形容搞笑心情说说大全
- 9 适合发关于流浪地球的说说
- 10 微信说说要点开