E D R , A S I H C RSS

Calendar환�코드

아마�.cpp

#include <stdio.h>
#include "랄랄�랄�랄랄.h"


int main(void){
	int numberofDay, year, month;

	printf("�하시는 년�를 입력해주세요 : ");
	scanf("%d", &year);
	printf("1월 1�� 요�� �어주세요(�요�:0 ~ 토요� : 6) : ");
	scanf("%d", &numberofDay);

	while(numberofDay < 0 || numberofDay > 6){
		printf("다시 입력하세요 : ");
		scanf("%d", numberofDay);
	}

	printf("\n");
	for(month = 1;month <= 12;month++){

		달력ìœë ¥(numberofDay, year, month);
		numberofDay = 몇요�로시작할까(numberofDay, year, month);

	}

	return 0;
}

랄랄�랄�랄랄.h

#include <stdio.h>

int 윤달계산(int year);
int 달력형�(int nameofDay, int year, int month);
int 달력ìœë ¥(int 몇요ì�¼, int 몇년, int 몇월);
int 몇요�로시작할까(int 요�, int 년�, int 월);

랄랄�랄�랄랄.cpp

#include "랄랄�랄�랄랄.h"

int 윤달계산(int year){
	if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0){
		return 29;
	}
	else
	{
		return 28;
	}
}

int 달력형�(int nameofDay, int year, int month){

	printf("		     %dì›”, %d\n", month, year);
	printf("---------------------------------------------------\n");
	printf("Sun	Mon	Tue	Wed	Thu	Fri	Sat\n");
	switch(nameofDay){
		case 0:
		break;

		case 1:
		printf("\t");
		break;

		case 2:
		printf("\t\t");
		break;

		case 3:
		printf("\t\t\t");
		break;

		case 4:
		printf("\t\t\t\t");
		break;

		case 5:
		printf("\t\t\t\t\t");
		break;

		case 6:
		printf("\t\t\t\t\t\t");
		break;

		default:
		break;


			
	}
	return 0;
}


int 달력ìœë ¥(int 몇요ì�¼, int 몇년, int 몇월){
	int endday, count�, count줄;
	
	if(몇월 == 1 || 몇월 == 3 || 몇월 == 5 || 몇월 == 7 || 몇월 == 8 || 몇월 == 10 || 몇월 == 12){
		endday = 31;
	}
	else if(몇월 == 4 || 몇월 == 6 || 몇월 == 9 || 몇월 == 11){
		endday = 30;
	}
	else
	{
		endday = 윤달계산(몇년);
	}

	달력형�(몇요�,몇년,몇월);

	for(count� = 1, count줄 = 몇요� + 1;count� <= endday; count�++, count줄++){
		printf("%d\t", count�);
		if(count줄 == 7){
			printf("\n");
			count줄 = 0;
		}
	}
	printf("\n\n");
	return 0;
}

int 몇요�로시작할까(int 요�, int 년�, int 월){
	
	int endday;
	
	if(ì›” == 1 || ì›” == 3 || ì›” == 5 || ì›” == 7 || ì›” == 8 || ì›” == 10 || ì›” == 12){
		endday = 31;
	}
	else if(ì›” == 4 || ì›” == 6 || ì›” == 9 || ì›” == 11){
		endday = 30;
	}
	else
	{
		endday = 윤달계산(년�);
	}

	return ((요� + endday) % 7);
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:48
Processing time 0.0034 sec