total.cpp
上传用户:hbzqs18
上传日期:2021-03-04
资源大小:46k
文件大小:2k
- // total.cpp : implementation file
- //
- #include "stdafx.h"
- #include "学生家庭经济情况调查系统.h"
- #include "total.h"
- #include "fstream.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // total dialog
- total::total(CWnd* pParent /*=NULL*/)
- : CDialog(total::IDD, pParent)
- {
- //{{AFX_DATA_INIT(total)
- //}}AFX_DATA_INIT
- }
- void total::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(total)
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(total, CDialog)
- //{{AFX_MSG_MAP(total)
- ON_WM_PAINT()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // total message handlers
- BOOL total::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- AnalysisData();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void total::AnalysisData()
- {
- CString str;
- int high=0,low=0;
- ifstream inf;
- inf.open("student.dat",ios::nocreate|ios::in);
- char stunum[10];
- char jiguan[20];
- int income;
- int members;
- while(true){
- inf.get(stunum,10,' ');
- stunum[9]=0;
- inf.seekg(1,ios::cur);
- inf>>jiguan;
- inf.seekg(1,ios::cur);
- inf>>income;
- if(income >= 500)
- high++;
- else
- low++;
- inf.seekg(1,ios::cur);
- inf>>members;
- if(inf.eof())break;
- inf.seekg(2,ios::cur);
- }
- inf.close();
-
- char buf[MAX_PATH];
- int total = low+high;
- float lowPart = (float)low/total;
- float highPart = (float)high/total;
- sprintf(buf,"人均月收入小于500元人数:%d,比例:%d%%",low, (int)(lowPart*100) );
- SetDlgItemText(IDC_RADIO1,buf);
- sprintf(buf,"人均月收入大于等于500元人数:%d,比例:%d%%",high,(int)(highPart*100) );
- SetDlgItemText(IDC_RADIO2,buf);
- }
- void total::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
-
- // TODO: Add your message handler code here
- AnalysisData();
- // Do not call CDialog::OnPaint() for painting messages
- }