2.有一个文档视图结构的多文档应用程序框架,在视图类的成员函数体内编写程序,要求:在屏幕的中央显示一个圆,在圆的中心显示一个注记——“武汉大学”(蓝色),鼠标点击圆的内部能够弹出一个对话框,显示圆的面积和周长。(所写的程序段需注明属于那个函数内,或者如有必要,可以自己添加成员函数)(10分)

void CMyGis2View::OnDraw(CDC* pDC)
{
}

void CMyGis2View::OnLButtonDown(UINT nFlags, CPoint point) 
{
CView::OnLButtonDown(nFlags, point);
}
3.有一段数字和字符,请按照ASCⅡ表的顺序设计一个排序算法进行排序,并将排序后的结果输出到文件名为result.dat的纯文本文件中。(需要写出一个完整的函数体,不能使用任何库函数):(10分)
WUHAN  R129  WHU  1893  Ress  Gis  Wh  RS

解决方案 »

  1.   

    在OnDraw中用GetClientRect(&rect),取的中心点,画半径为r的圆就是了,然后在OnLButton中检测鼠标是否点中这个圆了,点中了就显示一个对话框了
      

  2.   

    2.ascii码都有一个对应的整型常量,用起泡法就行了
      

  3.   

    void CMyGis2View::OnDraw(CDC* pDC)
    {
    CRect rect;
    CPoint center;
    CString str = "武汉大学";

    GetClientRect(&rect); //得到客户区矩形
    center = rect.CenterPoint(); //得到客户区中心
    rect.SetRect( //根据中心和半径设置圆所在矩形
    center.x-100,
    center.y-100,
    center.x+100,
    center.y+100
    );
    pDC->Ellipse(rect); //根据矩形绘制圆
    pDC->SetTextColor(RGB(0,0,255));//设置字体颜色
    pDC->TextOut(center.x-30,center.y-5,str);//显示字符串"武汉大学"
    }void CMyGis2View::OnLButtonDown(UINT nFlags, CPoint point) 
    {
    CRect rect;
    CString str;
    CRgn rgn;
    CPoint center;

    GetClientRect(&rect); //找到客户区矩形
    center = rect.CenterPoint(); //找到客户区中心点
    rect.SetRect( //跟据中心点和圆半径设置圆所在矩形
    center.x-100,
    center.y-100,
    center.x+100,
    center.y+100
    );
    rgn.CreateEllipticRgnIndirect(&rect); //根据举行设置圆形区域对象

    if (rgn.PtInRegion(point)) { //判断当前点击的位置是否在圆形区域内
    str.Format("圆半径:%.2lf 圆周长: %.2lf",3.14*100*100,2*3.14*100);
    AfxMessageBox(str); //计算面积,半径并显示
    }

    CView::OnLButtonDown(nFlags, point);
    }
      

  4.   

    void Sort(char* str, int length)
    {
    ofstream out("result.dat");
    char temp;
    int max;
    int i;
    int j; for (i=0; i<length; i++) {
    max = i;
    for (j=i; j<length; j++) {
    if (str[j] > str[i]) {
    max = j;
    }
    }
    if (max != i) {
    temp = str[i];
    str[i] = str[j];
    str[j] = temp;
    }
    out<<str[i];
    }
    }
      

  5.   

    void CMyGis2View::OnDraw(CDC* pDC)
    {
    CRect rect;
    CPoint center;
    CString str = "武汉大学";

    GetClientRect(&rect); //得到客户区矩形
    center = rect.CenterPoint(); //得到客户区中心
    rect.SetRect( //根据中心和半径设置圆所在矩形
    center.x-100,
    center.y-100,
    center.x+100,
    center.y+100
    );
    pDC->Ellipse(rect); //根据矩形绘制圆
    pDC->SetTextColor(RGB(0,0,255));//设置字体颜色
    pDC->TextOut(center.x-30,center.y-5,str);//显示字符串"武汉大学"
    }void CMyGis2View::OnLButtonDown(UINT nFlags, CPoint point) 
    {
    CRect rect;
    CString str;
    CRgn rgn;
    CPoint center;

    GetClientRect(&rect); //找到客户区矩形
    center = rect.CenterPoint(); //找到客户区中心点
    rect.SetRect( //跟据中心点和圆半径设置圆所在矩形
    center.x-100,
    center.y-100,
    center.x+100,
    center.y+100
    );
    rgn.CreateEllipticRgnIndirect(&rect); //根据举行设置圆形区域对象

    if (rgn.PtInRegion(point)) { //判断当前点击的位置是否在圆形区域内
    str.Format("圆半径:%.2lf 圆周长: %.2lf",3.14*100*100,2*3.14*100);
    AfxMessageBox(str); //计算面积,半径并显示
    }

    CView::OnLButtonDown(nFlags, point);
    }