万年历查询程序c语言(万年历c++编程)

今天给各位分享万年历查询程序c语言的知识,其中也会对万年历c++编程进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

1、求高手编写一个万年历的C语言程序2、万年历(C语言编程)3、C语言万年历查询系统4、c语言设计万年历

求高手编写一个万年历的C语言程序

#includestdio.h

#includestdlib.h

char* month_str[]={“January”,”February”,”March”,”April”,”May”,”June”,”July”,”August”,”September”,”October”,”November”,”December”};

char* week[]={“Sunday”,”Monday”,”Tuesday”,”Wednesday”,”Thursday”,”Friday”,”Saturday”};

int IsLeapYear(int year) /*find out the year is leap year or not*/

{

if((year%4==0year%100!=0)||(year%400==0))

return 1;

else

return 0;

}

int month_day(int year,int month)

{

int mon_day[]={31,28,31,30,31,30,31,31,30,31,30,31};

if(IsLeapYear(year)month==2)

return 29;

else

return(mon_day[month-1]);

}

int DaySearch(int year,int month,int day) /*search what day this day is*/

{

int c=0;

float s;

int m;

for(m=1;mmonth;m++)

c=c+month_day(year,m);

c=c+day;

s=year-1+(float)(year-1)/4+(float)(year-1)/100+(float)(year-1)/400-40+c;

return ((int)s%7);

}

int PrintAllYear(int year)/*print the all year*/

{

int temp;

int i,j;

printf(“\n\n%d Calander\n”,year);

for(i=1;i=12;i++)

{

printf(“\n\n%s(%d)\n”,month_str[i-1],i);

printf(“0 1 2 3 4 5 6 \n”);

printf(“S M T W T F S \n\n”);

temp=DaySearch(year,i,1);

for(j=1;j=month_day(year,i)+temp;j++)

{

if(j-temp=0)

printf(” “);

else if(j-temp10)

printf(“%d “,j-temp);

else

printf(“%d “,j-temp);

if(j%7==0)

printf(“\n”);

}

}

return 0;

}

int main()

{

int option,da;

char ch;

int year,month,day;

printf(“Copyright @ 2005 TianQian All rights reserved!:):):)”);

printf(“\n\nWelcome to use the WanNianLi system!\n”);

while(1)

{

printf(“\nPlease select the service you need:\n”);

printf(“\n1 Search what day the day is”);

printf(“\n2 Search whether the year is leap year or not”);

printf(“\n3 Print the calander of the whole year”);

printf(“\n4 Exit\n”);

scanf(“%d”,option);

switch(option)

{

case 1:

while(1)

{

printf(“\nPlease input the year,month and day(XXXX,XX,XX):”);

scanf(“%d,%d,%d,%c”,year,month,day);

da=DaySearch(year,month,day);

printf(“\n%d-%d-%d is %s,do you want to continue?(Y/N)”,year,month,day,week[da]);

fflush(stdin);

scanf(“%c”,ch);

if(ch==’N’||ch==’n’)

break;

}

break;

case 2:

while(1)

{

printf(“\nPlease input the year which needs searched?(XXXX)”);

scanf(“%d”,year);

if(IsLeapYear(year))

printf(“\n%d is Leap year,do you want to continue?(Y/N)”,year);

else

printf(“\n%d is not Leap year,do you want to continue(Y/N)?”,year);

fflush(stdin);

scanf(“%c”,ch);

if(ch==’N’||ch==’n’)

break;

}

break;

case 3:

while(1)

{

printf(“\nPlease input the year which needs printed(XXXX)”);

scanf(“%d”,year);

PrintAllYear(year);

printf(“\nDo you want to continue to print(Y/N)?”);

fflush(stdin);

scanf(“%c”,ch);

if(ch==’N’||ch==’n’)

break;

}

break;

case 4:

fflush(stdin);

printf(“Are you sure?(Y/N)”);

scanf(“%c”,ch);

if(ch==’Y’||ch==’y’)

exit(0);

break;

default:

printf(“\nError:Sorry,there is no this service now!\n”);

break;

}

}

return 0;

}

万年历查询程序c语言(万年历c++编程)

万年历(C语言编程)

#includestdio.h

#includetime.h

int leap (int year)//判断闰年

{

if(year%4==0year%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==2leap(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(NULL);

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”);

}

C语言万年历查询系统

/* welcome to use the WanNianLi system! */

#includestdio.h

#includestdlib.h

char* month_str[]={“January”,”February”,”March”,”April”,”May”,”June”,”July”,”August”,”September”,”October”,”November”,”December”};

char* week[]={“Sunday”,”Monday”,”Tuesday”,”Wednesday”,”Thursday”,”Friday”,”Saturday”};

int IsLeapYear(int year) /*find out the year is leap year or not*/

{

if((year%4==0year%100!=0)||(year%400==0))

return 1;

else

return 0;

}

int month_day(int year,int month)

{

int mon_day[]={31,28,31,30,31,30,31,31,30,31,30,31};

if(IsLeapYear(year)month==2)

return 29;

else

return(mon_day[month-1]);

}

int DaySearch(int year,int month,int day) /*search what day this day is*/

{

int c=0;

float s;

int m;

for(m=1;mmonth;m++)

c=c+month_day(year,m);

c=c+day;

s=year-1+(float)(year-1)/4+(float)(year-1)/100+(float)(year-1)/400-40+c;

return ((int)s%7);

}

int PrintAllYear(int year)/*print the all year*/

{

int temp;

int i,j;

printf(“\n\n%d Calander\n”,year);

for(i=1;i=12;i++)

{

printf(“\n\n%s(%d)\n”,month_str[i-1],i);

printf(“0 1 2 3 4 5 6 \n”);

printf(“S M T W T F S \n\n”);

temp=DaySearch(year,i,1);

for(j=1;j=month_day(year,i)+temp;j++)

{

if(j-temp=0)

printf(” “);

else if(j-temp10)

printf(“%d “,j-temp);

else

printf(“%d “,j-temp);

if(j%7==0)

printf(“\n”);

}

}

return 0;

}

int main()

{

int option,da;

char ch;

int year,month,day;

printf(“Copyright @ 2005 TianQian All rights reserved!:):):)”);

printf(“\n\nWelcome to use the WanNianLi system!\n”);

while(1)

{

printf(“\nPlease select the service you need:\n”);

printf(“\n1 Search what day the day is”);

printf(“\n2 Search whether the year is leap year or not”);

printf(“\n3 Print the calander of the whole year”);

printf(“\n4 Exit\n”);

scanf(“%d”,option);

switch(option)

{

case 1:

while(1)

{

printf(“\nPlease input the year,month and day(XXXX,XX,XX):”);

scanf(“%d,%d,%d,%c”,year,month,day);

da=DaySearch(year,month,day);

printf(“\n%d-%d-%d is %s,do you want to continue?(Y/N)”,year,month,day,week[da]);

fflush(stdin);

scanf(“%c”,ch);

if(ch==’N’||ch==’n’)

break;

}

break;

case 2:

while(1)

{

printf(“\nPlease input the year which needs searched?(XXXX)”);

scanf(“%d”,year);

if(IsLeapYear(year))

printf(“\n%d is Leap year,do you want to continue?(Y/N)”,year);

else

printf(“\n%d is not Leap year,do you want to continue(Y/N)?”,year);

fflush(stdin);

scanf(“%c”,ch);

if(ch==’N’||ch==’n’)

break;

}

break;

case 3:

while(1)

{

printf(“\nPlease input the year which needs printed(XXXX)”);

scanf(“%d”,year);

PrintAllYear(year);

printf(“\nDo you want to continue to print(Y/N)?”);

fflush(stdin);

scanf(“%c”,ch);

if(ch==’N’||ch==’n’)

break;

}

break;

case 4:

fflush(stdin);

printf(“Are you sure?(Y/N)”);

scanf(“%c”,ch);

if(ch==’Y’||ch==’y’)

exit(0);

break;

default:

printf(“\nError:Sorry,there is no this service now!\n”);

break;

}

}

return 0;

}

c语言设计万年历

/*不过除了没有查询某年某月某日是这一年的第几天。。和判断这一年的生肖外,都能满足你的要求。

加点金币帮你完善点!*/

#includestdio.h

int

Swiss(int

Years)

//判断是否是闰年

{

if(!(Years%100))

{

Years=Years/100;

}

if(Years%4)

{

return

0;

}

else

{

return

1;

}

}

int

Number(int

Yearsa,int

Yearsb)

//已知两个年份,求出两个年份之间闰年的个数

{

int

i=Yearsa+1;

int

mou=0;

do{

if(Swiss(i))

{

mou++;

}

i++;

}while(iYearsb);

return

mou;

}

int

Mvalue(int

Years,int

Month,int

Day)

//已知年月日,求出某年某月某日是星期几

{

int

M[12]={0,3,3,6,1,4,6,2,5,0,3,5};

//月值

int

N=6;

//年值初始化

int

a;

if(Years2006)

//求年值,年值以2006年为基数

{

N=6-((2006-Years)%7)-Number(Years,2006);

if(Swiss(Years))

{

if(Month3)

{

N–;

}

}

}

else

if(Years2006)

{

N=((Years-2006)%7)-1+Number(2006,Years);

if(Swiss(Years))

{

if(Month2)

{

N++;

}

}

}

a=(Day+M[Month-1]+N)%7;

//某年某月某日是星期几=(日值+月值+年值)%7

return

a;

}

int

Amonth(int

Month)

//已知月,求出这个月是大月还是小月

{

switch(Month)

{

case

1:

case

3:

case

5:

case

7:

case

8:

case

10:

//1,3,5,7,8,10,12是大月,没月31天

case

12:return

1;

case

4:

case

6:

case

9:

case

11:return

0;

//4,6,9,11是小月,每月30天

case

2:return

2;

//二月份

}

return

-1;

}

void

main

()

{

int

Dtable[7][7];

int

i,j;

int

Years=9999;

int

Month=12;

int

Day=1;

int

b;

for(i=0;i7;i++)

//初始化数组

{

Dtable[0][i]=i;

}

for(i=1;i7;i++)

{

for(j=0;j7;j++)

{

Dtable[i][j]=0;

}

}

i=Mvalue(Years,Month,Day);

switch(Amonth(Month))

{

case

0:b=30;break;

case

1:b=31;break;

case

2:if(Swiss(Years))b=29;else

b=28;break;

//闰年2月29天,平年二月28天

default:b=-1;break;

}

for(;i7;i++)

{

Dtable[1][i]=Day++;

}

for(i=2;i7;i++)

{

for(j=0;j7;j++)

//建造日历表

{

if(Day=b)

{

Dtable[i][j]=Day++;

}

else

{

continue;

}

}

}

printf(“%d:%d\n”,Years,Month);

for(i=0;i7;i++)

//输出日历表

{

for(j=0;j7;j++)

{

printf(“%3d”,Dtable[i][j]);

}

printf(“\n”);

}

getch();

//完毕!

}

万年历查询程序c语言的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于万年历c++编程、万年历查询程序c语言的信息别忘了在本站进行查找喔。

本文来自投稿,不代表【】观点,发布者:【

本文地址: ,如若转载,请注明出处!

举报投诉邮箱:253000106@qq.com

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2024年4月3日 01:33:21
下一篇 2024年4月3日 01:41:31

相关推荐

  • c语言改写模式,c语言实现修改功能

    c语言程序修改? 1、这个程序有4个错误,我都加粗了,第一个是m没有赋初值,第二个是while表达式中的ch=getchar()需要括号括起来,第三个是m=m*10+ch-0中的0也需要用单引号括起来,第四个是第2个while中为m!=0。 2、define容易造成误会,因为不符合一般的编程习惯,false 0, true 1;scanf放在你的那个地方是达…

    2024年5月23日
    3900
  • c语言控制代码的换码序列,c语言交换代码

    求C语言编程大神解答一下下面这个编程代码? k==5,用5去除125余0,所以r=125%5中r为0。由于!0为1,所以执行while循环体:先打印出5(k的值),再n=n/k==125/5=25;由于251则再打印出*号。这一循环结果输出是5*。 下面是我的代码,三个函数分别对应三个问题。 在实现基本要求的前提下,拓展了可以从键盘输入的功能,以下为各题代码…

    2024年5月23日
    5600
  • c语言扫描io脚状态,c语言端口扫描

    求51单片机的上升沿和下降沿C语言检测程序列子,端口就是普通IO口。 上升沿触发是当信号有上升沿时的开关动作,当电位由低变高而触发输出变化的就叫上升沿触发。也就是当测到的信号电位是从低到高也就是上升时就触发,叫做上升沿触发。 单片机怎么计算1s内下降沿的个数的C语言程序或者计算两个下降沿的时间(检测脉冲频率)计算1s内下降沿的个数方法是,一个定时器设置定时1…

    2024年5月23日
    4400
  • c语言mallloc使用的简单介绍

    C语言中使用malloc必须加#includemallo.h? 1、在C语言中使用malloc函数进行动态内存分配。malloc的全称是memory allocation,中文叫动态内存分配。原型:extern void malloc(unsigned int num_bytes);功能:分配长度为num_bytes字节的内存块。 2、你可以看一下C语言那本…

    2024年5月23日
    4400
  • c语言三位小数,C语言三位小数

    怎样用C++语言输出精确到小数点后三位的数? 1、用C++语言输出精确到小数点后三位的数,可以参考下面给出的代码:coutsetiosflags(ios:fixed)setprecision(3)。其中 setiosflags中set是设置的意思。ios是iostream的缩写,即输入输出流。flags是标志的意思。 2、要精确到小数点后若干位,则数据类型为…

    2024年5月23日
    7200
  • c语言21点游戏,二十一点游戏代码c语言

    如何使用C语言编写简单小游戏? 1、数学知识:长方形的面积S=a*b 长方形周长L=2*(a+b)其中a b分别为长方形的宽和高。算法分析:长方形面积及周长均依赖于宽和高,所以先要输入宽高值,然后根据公式计算,输出结果即可。 2、/*也不知道你是什么级别的,我是一个新手,刚接触编程语言,以下是我自己变得一个小程序,在所有c语言的编译器(vc++0、turbo…

    2024年5月23日
    6300
  • c语言当中的null,C语言当中的符号

    C/C++中,NULL和null的区别是什么? nul 和 null要看编译器,不同的编译器有所区别。 所以C或者C++中都使用一个特殊定义NULL表示无效值,其本质就是未定义具体数据类型的0值。 null是是什么都没有的意思。在java中表示空对象。 本意是“空的;元素只有零的”意思。计算机中通常表示空值,无结果,或是空集合。\x0d\x0a在ASCII码…

    2024年5月23日
    4500
  • 包含c语言对txt文件命名的词条

    如何在C语言编程里面修改源文件名字 如果你是在WINDOWS的话,简单了,随便用个编辑器,比如记事本,然后写c源程序,保存到你想要保存的位置。如果你在DOS下,可以用edit,写好以后,按alt键,选择文件菜单,然后保存。 用open打开文件,注意操作模式使用“修改”或者“添加” 用write或者fprintf向文件中写入你的内容。 用close关闭文件。 …

    2024年5月23日
    4800
  • 学c语言编程,学c语言编程用什么软件

    编程开发必须要学C语言吗? 1、要学习。编程开发的学习内容主要包括c语言、python和c+语言。C语言作为一种简单灵活的高级编程语言,它是一个面向过程的语言,一般是作为计算机专业的基础入门语言课程。 2、C语言。对于刚接触编程的人来说,先学习C语言是非常重要的。C语言可以说是是计算机编程语言的鼻祖,其他的编程语言几乎全是由C语言变化衍生出来的。 3、不需要…

    2024年5月23日
    3400
  • c语言用string定义字符串,c语言中用string类型来处理字符串类型

    C++怎样定义定义字符串 1、第一是字符数组来表示字符串。用下面的语句声明:char a[10];C语言中字符数组与字符串的唯一区别是字符串末尾有一个结束符\0,而字符数组不需要。 2、在C中定义字符串有下列几种形式:字符串常量,char数组,char指针 字符串常量 即:位于一对双括号中的任何字符。双引号里的字符加上编译器自动提供的结束标志\0字符,作为 …

    2024年5月23日
    4300

发表回复

登录后才能评论



关注微信