國立暨南國際大學 101 學年度第二學期小考試卷

科目名稱:程式設計 開課系所:資訊工程 學系 任課教師
吳坤熹
系所別:
年級:
學號:
姓名:
考試日期
2012.5.30

(考試時間: 08:10-08:20)

  1. (10%) If we replace the OnDraw() function in P.953 as below, what result will be shown on the screen after you run the program?  Please specify the coordinates of endpoints of each segment, or the coordinates of centers and boundaries.
    void CSketcherView::OnDraw(CDC* pDC)
    {
    CSketcherDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    if (!pDoc)
    return;

    const int n=3;
    const int unit = 100;
    for (auto i=1; i<=n+1; i++)
    {
    pDC->MoveTo(unit, i*unit);
    pDC->LineTo((n+1)*unit, i*unit);
    pDC->MoveTo(i*unit, unit);
    pDC->LineTo(i*unit, (n+1)*unit);
    }

    #define DrawO(p1, p2) pDC->Ellipse(p1.x, p1.y, p2.x, p2.y)
    #define DrawX(p1, p2) pDC->MoveTo(p1.x, p1.y); pDC->LineTo(p2.x, p2.y); \
    pDC->MoveTo(p1.x, p2.y); pDC->LineTo(p2.x, p1.y)

    DrawO(CPoint(220, 220), CPoint(280, 280));
    DrawX(CPoint(320, 120), CPoint(380, 180));
    }