JavaScript 星座计算两个Demo

方法一

var constellations = [
    {"Start":121,"End":220,"Name":"水平座"},    {"Start":221,"End":320,"Name":"双鱼座"},
    {"Start":321,"End":420,"Name":"白羊座"},    {"Start":421,"End":520,"Name":"金牛座"},
    {"Start":521,"End":620,"Name":"双子座"},    {"Start":621,"End":720,"Name":"巨蟹座"},
    {"Start":721,"End":820,"Name":"狮子座"},    {"Start":821,"End":920,"Name":"处女座"},
    {"Start":921,"End":1020,"Name":"天秤座"},       {"Start":1021,"End":1120,"Name":"天蝎座"},    
    {"Start":1121,"End":1220,"Name":"射手座"}    ];
    
function WhatIsYourConstellation(y,m,d)
{
    var daysInMonth = [31,99,31,30,31,30,31,31,30,31,30,31];
    
    if(y < 1970 || y > 2099) return;
    
    if(m < 1 || m > 12) return;
    
    var mDays = daysInMonth[m-1];
    
    if(m == 2)
    {
        mDays = GetSpecialDays(y)
    }

    if(d < 0 || d > mDays)  return;

    var pos = m * 100 + d;

    for(var i in constellations)
    {
        if(pos >= constellations[i].Start && pos  方法二

function valuateConstellation(month, date) {

var xingzuo = '';
switch (month) {
    case 3:
        if (date >= 21) {
            xingzuo = '白羊';
        } else {
            xingzuo = '双鱼';
        }
        break;
    case 4:
        if (date >= 21) {
            xingzuo = '金牛';
        } else {
            xingzuo = '白羊';
        }
        break;
    case 5:
        if (date >= 22) {
            xingzuo = '双子';
        } else {
            xingzuo = '金牛';
        }
        break;
    case 6:
        if (date >= 22) {
            xingzuo = '巨蟹';
        } else {
            xingzuo = '双子';
        }
        break;
    case 7:
        if (date >= 23) {
            xingzuo = '狮子';
        } else {
            xingzuo = '巨蟹';
        }
        break;
    case 8:
        if (date >= 23) {
            xingzuo = '处女';
        } else {
            xingzuo = '狮子';
        }
        break;
    case 9:
        if (date >= 24) {
            xingzuo = '天秤';
        } else {
            xingzuo = '处女';
        }
        break;
    case 10:
        if (date >= 24) {
            xingzuo = '天蝎';
        } else {
            xingzuo = '天秤';
        }
        break;
    case 11:
        if (date >= 23) {
            xingzuo = '射手';
        } else {
            xingzuo = '天蝎';
        }
        break;
    case 12:
        if (date >= 22) {
            xingzuo = '摩羯';
        } else {
            xingzuo = '射手';
        }
        break;
    case 1:
        if (date >= 21) {
            xingzuo = '水瓶';
        } else {
            xingzuo = '摩羯';
        }
        break;
    case 2:
        if (date >= 20) {
            xingzuo = '双鱼';
        } else {
            xingzuo = '水瓶';
        }
        break;
}
return xingzuo;

}

CreateProcess创建进程

STARTUPINFO         si = { 0 };
PROCESS_INFORMATION pi = { 0 };
si.cb = sizeof( si );
si.dwFlags = STARTF_USESIZE;
si.dwXSize = 100;
si.dwYSize = 200;
//创建进程
CreateProcess( "ChildProc.exe",
    "\"Hello Child\"",  
    NULL, NULL, FALSE,
    CREATE_NEW_CONSOLE, 
    NULL, NULL, &si, &pi );
//输出信息
printf( "Process Handle: %p\n", pi.hProcess );
printf( "Process ID: %d\n", pi.dwProcessId );
printf( "Thread Handle: %p\n", pi.hThread );
printf( "Thread ID: %d\n", pi.dwThreadId );