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

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

(考試時間: 16:30-16:45)

  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.
    void Ctest_drawView::OnDraw(CDC* pDC)
    {
    Ctest_drawDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    if (!pDoc)
    return;

    std::vector<CPoint> m_Points;
    m_Points.push_back(CPoint(10,10));
    m_Points.push_back(CPoint(20,20));
    m_Points.push_back(CPoint(30,30));
    m_Points.push_back(CPoint(40,40));

    int k = m_Points.size()-1;
    for (int i=0; i<=k/2; i++)
    pDC->Rectangle(m_Points[i].x, m_Points[i].y, m_Points[k-i].x, m_Points[k-i].y);
    }


  2. (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.

    void Ctest_drawView::OnDraw(CDC* pDC)
    {
    Ctest_drawDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    if (!pDoc)
    return;

    std::vector<CPoint> m_Points;
    m_Points.push_back(CPoint(10,10));
    m_Points.push_back(CPoint(20,20));
    m_Points.push_back(CPoint(30,30));
    m_Points.push_back(CPoint(40,40));
    m_Points.push_back(CPoint(50,50));

    int k = m_Points.size()-1;
    for (int i=0; i<=k/2; i++)
    pDC->Ellipse(m_Points[i].x, m_Points[i].y, m_Points[k-i].x, m_Points[k-i].y);
    }