看板 C_and_CPP 關於我們 聯絡資訊
UINT punUgly[1500]; punUgly[0] = 1; punUgly[1] = 2; if(unInput > 2) { for(UINT i = 2; i < unInput; i++) { BOOL bCheck = false; UINT unTmp = punUgly[i - 1] + 1; while(!bCheck) { bCheck = true; unTmp++; for(UINT j = 1; j < i; j++) { if(unTmp % punUgly[j] == 0) { bCheck = false; break; } } } punUgly[i] = unTmp; } } cout << "The 1500'th ugly number is <" << punUgly[1499] << ">." << endl; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 124.219.8.189
bleed1979:這個和題意似乎有點不同 11/05 16:13
ledia:還差滿多的 ^^|| 11/05 16:46