题库(5)_输入年份和这一年第一天是星期几,制作日历

输入年份和这一年第一天是星期几,制作日历

​#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#define bigmonth 31
#define simmonth 30
#define bigFeb 29
#define simFeb 28

void math(int *day, int daysOfmonth)
{ 
	int numberOfline=0; 
	printf("Sun Mon Tue Wed Thu Fri Sat\n");
	//putchar('\n');
	if (*day != 7)
	{//不是星期日,打印空格填充
		for (int i = 0; i <* day; i++)
		{
			numberOfline++;
			printf("    " );
		}
	}
	//打印数字
	for (int i = 1; i <= daysOfmonth; i++)
	{
		numberOfline++;
		if (numberOfline % 7 == 0)
		{
			printf("%2d\n", i);
		}
		else
		{
			printf("%2d  ", i);
		}
	}
	putchar('\n');
	putchar('\n');
	putchar('\n');
	*day = (*day + daysOfmonth % 7)%7;
}

//判断闰年
void method(int year,int *day)
{
	if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0))
	{
		printf("%d-January\n", year); 
		putchar('\n');
		math(day, 31);
		printf("%d-Febuary\n", year);
		putchar('\n');
		math(day, 29);
		printf("%d-March\n", year);
		putchar('\n');
		math(day, 31);
		printf("%d-April\n",year);
		putchar('\n');
		math(day, 30);
		printf("%d-May\n",year);
		putchar('\n');
		math(day, 31);
		printf("%d-June\n",year);
		putchar('\n');
		math(day, 30);
		printf("%d-July\n",year);
		putchar('\n');
		math(day, 31);
		printf("%d-August\n",year);
		putchar('\n');
		math(day, 31);
		printf("%d-September\n",year);
		putchar('\n');
		math(day, 30);
		printf("%d-October\n", year);
		putchar('\n');
		math(day, 31);
		printf("%d-Noveber\n", year);
		putchar('\n');
		math(day, 30);
		printf("%d-Dacember\n", year);
		putchar('\n');
		math(day, 31);
	}
	else
	{
		printf("%d-January\n", year);
		putchar('\n');
		math(day, 31);
		printf("%d-Febuary\n", year);
		putchar('\n');
		math(day, 28);
		printf("%d-March\n", year);
		putchar('\n');
		math(day, 31);
		printf("%d-April\n", year);
		putchar('\n');
		math(day, 30);
		printf("%d-May\n", year);
		putchar('\n');
		math(day, 31);
		printf("%d-June\n", year);
		putchar('\n');
		math(day, 30);
		printf("%d-July\n", year);
		putchar('\n');
		math(day, 31);
		printf("%d-August\n", year);
		putchar('\n');
		math(day, 31);
		printf("%d-September\n", year);
		putchar('\n');
		math(day, 30);
		printf("%d-October\n", year);
		putchar('\n');
		math(day, 31);
		printf("%d-Noveber\n", year);
		putchar('\n');
		math(day, 30);
		printf("%d-Dacember\n", year);
		putchar('\n');
		math(day, 31);;

	}	
}

int main()
{
	int day = 2;
	int year = 2019;
	method(year,&day);
	system("pause");
	return 0;
}


​
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值