📄 exam1_1view.cpp
字号:
// exam1_1View.cpp : implementation of the CExam1_1View class
//
#include "stdafx.h"
#include "exam1_1.h"
#include "exam1_1Doc.h"
#include "exam1_1View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExam1_1View
IMPLEMENT_DYNCREATE(CExam1_1View, CView)
BEGIN_MESSAGE_MAP(CExam1_1View, CView)
//{{AFX_MSG_MAP(CExam1_1View)
ON_WM_RBUTTONDOWN()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExam1_1View construction/destruction
CExam1_1View::CExam1_1View()
{
// TODO: add construction code here
}
CExam1_1View::~CExam1_1View()
{
}
BOOL CExam1_1View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CExam1_1View drawing
void CExam1_1View::OnDraw(CDC* pDC)
{
CExam1_1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CExam1_1View printing
BOOL CExam1_1View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CExam1_1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CExam1_1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CExam1_1View diagnostics
#ifdef _DEBUG
void CExam1_1View::AssertValid() const
{
CView::AssertValid();
}
void CExam1_1View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CExam1_1Doc* CExam1_1View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExam1_1Doc)));
return (CExam1_1Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CExam1_1View message handlers
void CExam1_1View::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
int num[10]; //求均值
int sum=0;
int average;
for(int i=0;i<=9;i++)
num[i]=2*(i+1);
for(i=0;i<10;i++)
sum=sum+num[i];
average=sum/10;
CString message; //将int型数据转换为Cstring型
message.Format("%d",average);
MessageBox(message); //在对话框中显示结果
CView::OnRButtonDown(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -