More actions
imported>smksyj No edit summary |
(Repair batch-0001 pages from live compare) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
== 아마도.cpp == | == 아마도.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 == | == 랄랄라랄라랄랄.h == | ||
#include <stdio.h> | #include <stdio.h> | ||
| Line 107: | Line 134: | ||
return ((요일 + endday) % 7); | return ((요일 + endday) % 7); | ||
} | } | ||
Latest revision as of 23:56, 26 March 2026
아마도.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);
}