sihao chongya

master
parent 1247a58d97
commit c3a309b461

@ -0,0 +1,357 @@
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int Year(int A)/*计算输入年份之前一共多少天*/
{
int i,day,s=0;
for(i=1;i<=A-1;i++)
{
if( i%4==0 && i%100!=0 || i%400==0 )/*判断是否为闰年*/
day=366;
else
day=365;
s=s+day;
}
return s;
}
int Month(int B,int C)/*计算输入月份有多少天*/
{
enum monthday{Jan=1,Feb=2,Mar=3,Apr=4,May=5,Jun=6,Jul=7,Aug=8,Sept=9,Nov=11,Oct=10,Dec=12};/*枚举*/
switch(C)
{
case Jan:
return 31;
case Feb:
if( B%4==0 && B%100!=0 || B%400==0 )
return 29;
else
return 28;
case Mar:
return 31;
case Apr:
return 30;
case May:
return 31;
case Jun:
return 30;
case Jul:
return 31;
case Aug:
return 31;
case Sept:
return 30;
case Oct:
return 31;
case Nov:
return 30;
case Dec:
return 31;
default:
return -1;
}
}
void Day(int E) /*计算查询天数是周几*/
{
switch(E)
{
case 1: printf("~~~~~~~~~~~~~~~~该天是星期一。又是元气满满的一周噢!~~~~~~~~~~~~~~~~~\n");break;
case 2: printf("~~~~~~~~~~~~~~该天是星期二。下午有公休,和小伙伴去吃个火锅吧!~~~~~~~~~~~~~~~\n"); break;
case 3: printf("~~~~~~~~~~~~该天是星期三。一天的满课,努力奋斗吧,加油你是最胖的!~~~~~~~~~~~~~\n") ;break;
case 4: printf("~~~~~~~~~~~~~该天是星期四。期待的体育课来啦!一起锻炼身体吧!~~~~~~~~~~~~~~\n");break;
case 5: printf("~~~~~~~~~~~~~~~该天是星期五。最后一天的学习不能懈怠鸭!~~~~~~~~~~~~~~~~\n");break;
case 6: printf("~~~~~~~~~~~~该天是星期六。终于可以睡个懒觉啦~是不是贼开心鸭!~~~~~~~~~~~~~\n");break;
case 0: printf("~~~~~~~~~~~~~该天是星期天。迎接新一周的学习,记得做好预习鸭!~~~~~~~~~~~~~~\n");break;
}
}
void Holiday(int F,int G) /*判断是否为公历节日*/
{
if( F==1&&G==1||F==5&&G==1||F==10&&G==1||F==3&&G==8||F==3&&G==12||F==5&&G==4||F==6&&G==1||F==7&&G==1||F==8&&G==1||F==9&&G==10)
printf(" ~~当天是公历节日!~~\n");
else
printf(" ~~当天不是公历节日~~\n");
}
void huanying() //欢迎界面
{
system("color 0D");
float y,x;
for ( y = 1.5f; y > -1.5f; y -= 0.1f)
{
for ( x = -1.5f; x < 1.5f; x += 0.05f)
{
float a = x * x + y * y - 1;
putchar(a * a * a - x * x * y * y * y <= 0.0f ? '*' : ' ');
}
putchar('\n');
}
printf("=======================好程序,中原造=======================");
Sleep(1000);//延时
system("cls");//清屏
}
struct zuozhe
{
int age;
float h;
float w;
};
int caidan()
{
FILE *fp;
fp=fopen("彩蛋解析.txt","w");
printf("\n~~~~~~~~~~~~~~~~~~~~~~~亲功能选择666会有惊喜噢~~~~~~~~~~~~~~~~~~~~~~~~");
fclose(fp);
}
void main()
{
int year,month,day,year1,month1,day1,d,j,Z,d1,d2,D,cha,Z1,hui,gong,s=-1;
huanying();
system("color 0E");
printf("******************************************************************************\n");/*78个*由此可知DEVC++一行最多80个字符*/
printf("* *\n");
printf("* *\n");
printf("*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~欢迎您的使用~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*\n");
printf("* *\n");
printf("* *\n");
printf("******************************************************************************\n");
printf("本程序有如下功能:\n\n");
printf("1.输入一个年份输出是在屏幕上显示该年的日历。假定输入年份在1940-2040之间。\n\n");
printf("2.输入年月,输出该月的日历。\n\n") ;
printf("3.输入年月日,输出距今天还有多少天,星期几,是否是公历节日。\n\n");
hui=1;
while(hui==1) //判断用户是否重复使用程序
{
do
{
printf("请输入您要使用的功能:");
scanf ("%d",&gong);
printf("\n");
switch(gong)
{
case 1:
{
printf("输入你所查询的年份:");
scanf ("%d",&year);
while(year==0)
{
printf("\n没有0年呢~\n\n");
printf("请重新输入查询年份:") ;
scanf("%d",&year) ;
}
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\n %d年\n\n",year);
Z=Year(year); //Z表示到目前年份为止总天数
for(j=1;j<=12;j++) //循环来显示1~12月天数
{
d=Z%7+1; //d表示该年第一天是星期几余数为7则为星期天
printf("==================================\n"); //34个=
printf (" %d月份\n",j);
printf ("周日 周一 周二 周三 周四 周五 周六\n");
if(d<7) //周日放在了首位,不用空格
for(d1=1;d1<=d;d1++)
printf(" "); //5个空格
for(d2=1;d2<=Month(year,j);d2++) //d2表示该月的天数
{
printf("%d",d2);
if(d2<10)
printf(" "); //4个空格
else
printf(" "); //3个空格
if((d2+d)%7==0 || d2==Month(year,j)) //控制换行
printf("\n");
}
Z=Z+Month(year,j); //输入下一个月日历
}
break;
}
case 2:
{
printf("输入所查询的年份:");
scanf ("%d",&year);
while(year==0)
{
printf("\n没有0年呢~\n\n");
printf("请重新输入查询年份:") ;
scanf("%d",&year) ;
}
printf("\n输入所查询的月份:");
scanf ("%d",&month);
while(month!=1&&month!=2&&month!=3&&month!=4&&month!=5&&month!=6&&month!=7&&month!=8&&month!=9&&month!=10&&month!=11&&month!=12)
{
printf("\n一年只有12个月噢请输入1~12的整数~\n\n");
printf ("请重新输入月份:");
scanf("%d",&month);
}
printf("\n");
Z=Year(year);
for(j=1;j<=month-1;j++) //计算查询月份之前的总天数
{
D=Month(year,j);
Z=Z+D;
}
d=Z%7+1;
printf("==================================\n\n");
printf(" %d年\n\n",year);
printf (" %d月份\n\n",j);
printf ("周日 周一 周二 周三 周四 周五 周六\n");
if (d<7)
for (d1=1;d1<=d;d1++)
printf(" ");
for (d2=1;d2<=Month(year,j);d2++)
{
printf ("%d",d2);
if (d2<10)
printf (" ");
else
printf (" ");
if ((d2+d)%7==0 || d2==Month(year,j))
printf ("\n");
}
break;
}
case 3:
{
printf("==================================\n\n");
printf ("请输入查询年份:");
scanf ("%d",&year);
while(year==0)
{
printf("\n没有0年呢~\n\n");
printf("请重新输入查询年份:") ;
scanf("%d",&year) ;
}
printf ("\n请输入查询月份:");
scanf ("%d",&month);
while(month!=1&&month!=2&&month!=3&&month!=4&&month!=5&&month!=6&&month!=7&&month!=8&&month!=9&&month!=10&&month!=11&&month!=12)
{
printf("\n一年只有12个月噢请输入1~12的整数~\n\n");
printf ("请重新输入月份:");
scanf("%d",&month);
}
printf ("\n请输入查询号数:");
scanf ("%d",&day);
while(day>Month(year,month)||day<1)
{
printf("\n亲,这个月没有这么多天噢!\n\n");
printf("这个月只有%d天~",Month(year,month));
printf("\n\n请重新选择当日号数:");
scanf("%d",&day);
}
printf("\n") ;
Z=Year(year);
for(j=1;j<=month-1;j++)
{
D=Month(year,j);
Z=Z+D;
}
Z=Z+day;
printf("----------------------------------\n\n");
printf("请输入当前年份:");
scanf ("%d",&year1);
while(year1==0)
{
printf("\n没有0年呢~\n\n");
printf("请重新输入查询年份:") ;
scanf("%d",&year1) ;
}
printf("\n请输入当前月份:");
scanf ("%d",&month1);
while(month1!=1&&month1!=2&&month1!=3&&month1!=4&&month1!=5&&month1!=6&&month1!=7&&month1!=8&&month1!=9&&month1!=10&&month1!=11&&month1!=12)
{
printf("\n一年只有12个月噢请输入1~12的整数~\n\n");
printf ("请重新输入月份:");
scanf("%d",&month1);
}
printf("\n请输入当日号数:");
scanf ("%d",&day1);
while(day1>Month(year1,month1)||day1<1)
{
printf("\n亲,这个月没有这么多天噢!\n\n");
printf("这个月只有%d天~",Month(year1,month1));
printf("\n\n请重新选择当日号数:");
scanf("%d",&day1);
}
printf("\n==================================\n\n");
Z1=Year(year1);
for (j=1;j<=month1-1;j++)
{
D=Month(year1,j);
Z1=Z1+D;
}
Z1=Z1+day1;
cha=Z-Z1;
printf("输入日期距今还有%d天\n\n",cha);
d=Z%7;
Day(d); //计算查询天是星期几
printf("\n");
Holiday(month,day) ;
break;
}
case 666:
{
struct zuozhe Zzy;//录入各个信息
Zzy.age=19;
Zzy.h=174.1;
Zzy.w=66.6;;
printf(" |==========================================|\n"); //15个空格
printf(" | 作者信息 |\n");
printf(" | 姓名:张中原 |\n");
printf(" | 年龄:%2.d |\n",Zzy.age);
printf(" | 身高:%.1fcm |\n",Zzy.h);
printf(" | 体重:%.1fkg |\n",Zzy.w);
printf(" | 爱好:跑步 |\n");
printf(" |==========================================|\n");
break;
}
case 999:
{
int i;
int l;
char A[20]={"I LOVE YOU"};
i = 3;//'i'的值可以随便改
printf("\n %10c%10c\n %7c%6c%4c%6c\n", i, i, i, i, i, i);
printf(" %5c%10c%10c\n %6c %s%4c\n", i, i, i, i, A, i);
printf(" %8c%14c\n %10c%10c\n %12c%6c\n", i, i, i, i, i, i);
printf(" %14c%2c\n %14c%2c\n", i, i, i, i);
printf(" %8c%6c%2c%6c\n", i, i, i, i);
printf(" %7c %c %c %c%4c %c %c %c\n", i, i, i, i, i, i, i, i, i);
printf(" %7c %c %c %c %c %c %c %c %c\n", i, i, i, i, i, i, i, i, i);
for (l = 0; l < 10; l++)
{
printf(" %14c%c%c\n", i, i, i);
}
caidan();
break;
}
default:
{
printf("亲,没有此功能噢!\n\n");
printf("请您重新输入所选择的功能!\n\n") ;
break;
}
}
}while(gong!=1&&gong!=2&&gong!=3&&gong!=666&&gong!=999);
printf("\n");
printf("继续使用请按1\n\n退出程序请按2。\n\n请输入您的选择:");
scanf("%d",&hui);
while(hui!=1&&hui!=2)
{
printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
printf("亲,小本程序,没有别的功能了噢!");
printf("\n\n请选择1或者2噢~\n\n");
printf("继续使用请按1\n\n退出程序请按2。\n\n请再次输入您的选择:");
scanf("%d",&hui);
}
printf("\n");
if(hui==1)
{
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~重温我们的功能叭!~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
printf("1.输入一个年份输出是在屏幕上显示该年的日历。假定输入年份在1940-2040之间。\n\n");
printf("2.输入年月,输出该月的日历。\n\n") ;
printf("3.输入年月日,输出距今天还有多少天,星期几,是否是公历节日。\n\n");
}
else
{
printf("=========================感谢您对本程序的使用!=========================\n");
}
}
}

Binary file not shown.
Loading…
Cancel
Save