C언어, 요일계산과 입력한 달의 달력출력 프로그램 완성소스입니다..
세이
#include stdio.h
int month_total[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int get_week(int , int , int );
void Calendar(int ,int ,int );
void main() {
char *week_total[] ={일,월,화,수,목,금,토};
int year = 0, month = 0, day = 0 ,get;
printf(\n);
printf(*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n);
printf( 년,월,일을 입력하면 요일 출력 프로그램 \n);
printf( 입력한 날의 달력을 출력하는 프로그램 \n);
printf(*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n);
printf(\n);
printf(요일을 원하는 날짜를 입력해 주세요 !! 예)2009 11 03\n);
printf(\n);
printf(\t\t);
scanf(%d %d %d,&year,&month,&day);
get = get_week(year, month, day);
printf(\n);
printf( *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* \n);
printf( %d년 %d월 %d일 → %s요일 입니다 \n,year,month,day,week_total[get]);
printf( *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* \n);
printf(\n);
printf(\n);
printf( *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* \n);
printf( %d년 %d월 의 달력입니다. \n,year,month,week_total[get]);
printf( *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* \n);
Calendar(year,month,day);
printf(\n);
printf(\n);}
int get_week(int year, int month, int day)
{
int day_total=0,month_total_01=0,day_total_01, temp;
int i;
if((year%4)==0 && ((year%100)!=0 || (year%400)==0))
{
month_total[2] = 29;
}
day_total =(year-1)/4-(year-1)/100+(year-1)/400;
day_total_01 = (year-1)*365 + day + day_total;
for(i=0;imonth;i++)
{
day_total_01 += month_total[i];
}
temp = day_total_01 % 7;return temp;
}
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
void Calendar(int year,int month,int day)
{
int month_daty_01[]={31,28,31,30,31,30,31,31,30,31,30,31};
int month_daty_02[]={0,31,28,31,30,31,30,31,31,30,31,30};
int gesan;
int date=0,total_day;
int i,count=0;
if(month==2 && year%100!=0 && year%4==0)
{
month_daty_01[month-1]=month_daty_01[month01[month-1]+1; // 29
}
if(month==2 && year%400==0)
{
month_daty_01[month-1]=month_daty_01[month-1]+1; // 29
}
total_day=(year-1)/4-(year-1)/100+(year-1)/400;
date=(year-1)*365+total_day;
for(i=0;imonth;i++)
{
date=date+month_daty_02[i];
}
printf(일\t월\t화\t수\t목\t금\t토\n);
gesan=date%7+1;
if(gesan==7)
{
gesan=0;
}
for(i=0;igesan;i++)
{
printf( \t);
count++;
}
for(i=1;i=month_daty_01[month-1];i++)
{
if(count!=0&&count%7==0)
{
printf(\n);
}
count++;
printf(%d\t,i);
}
printf(\n);
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
}
이번 수업시간에 만들어본 사용자가 입력한 날짜, 즉 2009 11 03 을 입력하면
화요일 이라는 결과와 11월달에 대한 달력이 나오는 소스입니다.
요일을 계산하는 함수부분은 제가 직접했지만
달력이 나오는 (-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*) 이 부분은 친구의 소스를 빌려서 만들어봤습니다.
이해가 안되는 부분이 많아서 그런데
저 부분만 위에서부터 주석좀 해주시면 감사합니다..
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2654959 | ===========-이런거 미리 지정하는법 (1) | 김자영 | 2024-05-15 |
2654930 | 도와주십시요 ㅜㅜ 자료구조 ㅜㅜ | 도널드 | 2024-05-15 |
2654881 | PID 모듈 검색 부분 질문합니다 . | 이름없음 | 2024-05-14 |
2654850 | 조건에 만족하는 다음 수를 찾고 싶습니다. | 초엘 | 2024-05-14 |
2654790 | 두파일간 byte단위 txt파일 복사 中 | 슬찬 | 2024-05-14 |
2654768 | 사전만들기 입니다. | 여우By | 2024-05-13 |
2654716 | c언어 고수님들 답좀적어주세요 급합니다 ㅠㅠ | 한말글 | 2024-05-13 |
2654688 | c언어 ㅠㅠ 너 무 어려 워요 ㅠ 도와주세요!! | 별빛 | 2024-05-13 |
2654659 | 구구단 소스 궁금한 점 도움 부탁드립니다! (2) | 미련곰팅이 | 2024-05-12 |
2654633 | 오류가 무었인가요..? (2) | 단순랩퍼 | 2024-05-12 |
2654603 | 어디가 잘못된지를 모르겠습니다. 한 번 봐주세요...ㅠ (2) | 글고운 | 2024-05-12 |
2654574 | 소스 추가좀 부탁드립니다. (등수 출력) | 크리미걸 | 2024-05-12 |
2654550 | 피보나치수열. (3) | 중독적 | 2024-05-11 |
2654521 | c초보 빙고관련게임... | 달콤이 | 2024-05-11 |
2654491 | 10진수를 2진수로 바꾸는법 (8) | 아잉 | 2024-05-11 |
2654412 | 빅오를 구하고 싶어요~ | 애기 | 2024-05-10 |
2654381 | 혼자 연구하는 c/c++ 질문 | 아잉 | 2024-05-10 |
2654352 | 행렬크기를 scanf로 입력받을수도 있나요..? | VanilLa | 2024-05-10 |
2654293 | 첫시작값과 끝값의 사이에 존재하는 정수들의 합을 구하는 것 (5) | 해긴 | 2024-05-09 |
2654185 | 64bit 환경에서 자료형의 크기가 좀궁그해요(완료) 더궁금한게 생겻어요(추가) (2) | 빈길 | 2024-05-08 |