http://blog.naver.com/wizhyo/100002563025
// 요일 구하기 /////////////////////////////////////////////////////////////////////
#include <stdio.h>
// 0 = Sunday
int day_of_week( int y, int m, int d )
{
static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
y -= m < 3;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
}
void main()
{
int y, m, d;
char *day[7] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
printf( "Enter date [yyyy mm dd]: " );
scanf( "%d %d %d", &y, &m, &d );
printf( "%s\n", day[day_of_week(y, m, d)] );
}
// 현재시간 구하기 /////////////////////////////////////////////////////////////////
#include <iostream>
#include <ctime>
#include <windows.h>
using namespace std;
void main()
{
// Windows API 함수 사용
SYSTEMTIME today;
GetSystemTime( &today );
cout <<today.wYear <<'/' <<today.wMonth <<'/' <<today.wDay <<endl;
// C런타임라이브러리 함수 사용
time_t ltime;
tm *ptoday;
ltime = time(0);
ptoday = localtime( <ime );
printf("%4d/%02d/%02d\n",
ptoday->tm_year + 1900, ptoday->tm_mon + 1, ptoday->tm_mday);
}