提交 ab1e2d06 编写于 作者: U u014427391

first commit

上级 b5fb5232
#include <iostream>
using namespace std;
#include <stdio.h>
#include <malloc.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define CLRSCR system("cls")
#define PRINT_TITLE "\n序号\t考号\t\t姓名\t语文\t数学\t英语\t总分\n"
#define PRINT_FORMAT "%d\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",i,p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score
#define WRITE_FORMAT "%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score
#define READ_FORMAT "%s %s %lf %lf %lf %lf",&p->stu.num,&p->stu.name,&p->stu.Chinese,&p->stu.math,&p->stu.English,&p->stu.count_score
//定义学生类
class student
{
public:
char num[9];
char name[7];//三个汉字长度为6个字节,应多定义一个字节来存放字符串结束符'\0'
double Chinese;
double math;
double English;
double count_score;
};
//定义单链表类
class node
{
public:
student stu;
node *next;
};
int MySelect(node * head,node *temp)
{
int i=0;
node *p,*tp=temp;
p=head->next;
FILE *fp;
char file[15]="English.txt";
if((fp=fopen(file,"w+"))==NULL)
{
printf("\n\t文件创建失败\n");
exit(0);
}
while (NULL!=p)
{
if(p->stu.English>100&&p->stu.count_score>300)
{
node *end;
end = (node *)malloc(sizeof(node));
tp->next=end;
tp=end;
tp->next=NULL;
tp->stu=p->stu;
if(i==0)
printf (PRINT_TITLE);
i++;
printf(PRINT_FORMAT);
if(p->next==NULL)//不要最后一行的回车,这样的话导入该文件时就不会有末尾的乱码
fprintf(fp,"%s\t%s\t%lf\t%lf\t%lf\t%lf",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score);
else
fprintf(fp,WRITE_FORMAT);
}
p=p->next;
}
fclose(fp);
if(i==0)
printf("\n\t英语超过100分且总分成绩超过300分的学生人数为零\n");
return i;
}
void Fprintf(node *head)
{
char file[15]="student.txt";
FILE *fp;
if((fp=fopen(file,"w"))==NULL)
{
printf("\n\t文件打开失败,按任意键退出\n");
getch();
exit(0);
}
node *p=head->next;
while(NULL!=p)
{
if(p->next==NULL)//不要最后一行的回车,这样的话导入该文件时就不会有末尾的乱码
fprintf(fp,"%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score);
else
fprintf(fp,WRITE_FORMAT);
p=p->next;
}
fclose(fp);
}
void InsertSort(node *head)//总分从大到小排序
{
node *p,*q,*u,*h,*w,*n;
int j=0;
p=head->next;
while(p!=NULL)
{
j++;
p=p->next;
}
for(int i=0;i<j-1;i++)
{
p=head;
q=p->next;
for(int z=0;z<=j-2-i;z++)
{
int y=0;
if((q->next->stu.count_score)>(p->next->stu.count_score))
{
n=q->next;
u=n->next;
w=p->next;
p->next=n;
n->next=w;
q->next=u;
p=p->next;
y=1;
}
if(y==0)
{
p=p->next;
q=q->next;
}
}
}
}
void FscanfFromFile(node *head)
{
char file[20]="student1.txt";
FILE *fp;
if((fp=fopen(file,"r"))==NULL)
{
printf("\n\t文件打开失败,按任意键退出\n");
getch();
exit(0);
}
node *p=head;
while(!feof(fp))
{
node *end;
end = (node *)malloc(sizeof(node));
p->next=end;
p=end;
p->next=NULL;
fscanf(fp,READ_FORMAT);
}
printf("\n\t信息导入成功\n");
InsertSort(head);
Fprintf(head);
fclose(fp);
}
void ShowList(node *head)//带头结点的链表
{
node *p=head->next;
int i=0;
printf ("\t\t\t成绩汇总排序表\n");
printf (PRINT_TITLE);
while(NULL!=p )
{ i++;
printf (PRINT_FORMAT);
p=p->next;
}
}
void FprintfToFile(node *head)
{
char file[15];
printf("\n输入要写入的文件名:");
scanf("%s",file);
FILE *fp;
if((fp=fopen(file,"w+"))==NULL)
{
printf("\n\t文件创建失败\n");
exit(0);
}
node *p=head->next;
while(NULL!=p)
{
if(p->next==NULL)//不要最后一行的回车,这样的话导入该文件时就不会有末尾的乱码
fprintf(fp,"%s\t%s\t%lf\t%lf\t%lf\t%lf",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score);
else
fprintf(fp,WRITE_FORMAT);
p=p->next;
}
fclose(fp);
printf("\n\t数据写入成功\n",file);//printf输出双引号要用转义字\"
}
node *ClearList(node *head)
{
node *p=head->next;
while(NULL!=p)
{
node *tp=p->next;
free(p);
p=tp;
}
return head->next=NULL;
}
int main()
{
node *head;
int i=0;
head = (node *)malloc(sizeof(node));
strcpy(head->stu.num," ");
strcpy(head->stu.name," ");
head->stu.Chinese=0;
head->stu.math=0;
head->stu.English=0;
head->stu.count_score=0;
node *temp= (node *)malloc(sizeof(node));//保存查找结果的头结点
printf("欢迎使用\n");
printf("\n----------------------------------------------\n");
FscanfFromFile(head);
char charget;
do
{
printf("\n----------------------------------------------\n");
printf("\n[1]信息显示\n");
printf("[2]挑选\n");
printf("[3]退出程序\n");
do
{
charget=getch();
}while((charget!='1')&&(charget!='2')&&(charget!='3'));
switch(charget)
{
case '1': ShowList(head);
printf("\n按任意键显示上层操作菜单\n");
getch();
break;
case '2': MySelect(head,temp);
printf("\n按任意键显示上层操作菜单\n");
getch();
break;
}//end switch,结束操作
}while(charget!='3');
return 0;
}
\ No newline at end of file
#include <iostream>
using namespace std;
#include <stdio.h>
#include <malloc.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define CLRSCR system("cls")
#define PRINT_TITLE "\n序号\t考号\t\t姓名\t语文\t数学\t英语\t总分\n"
#define PRINT_FORMAT "%d\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",i,p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score
#define WRITE_FORMAT "%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score
#define READ_FORMAT "%s %s %lf %lf %lf %lf",&p->stu.num,&p->stu.name,&p->stu.Chinese,&p->stu.math,&p->stu.English,&p->stu.count_score
#include<sstream>
string DoubleToString(double d)
{
//Need #include <sstream>
using namespace std;
string str;
stringstream ss;
ss<<d;
ss>>str;
return str;
}
//定义学生类
class student
{
public:
char num[9];
char name[7];//三个汉字长度为6个字节,应多定义一个字节来存放字符串结束符'\0'
double Chinese;
double math;
double English;
double count_score;
};
//定义单链表类
class node
{
public:
student stu;
node *next;
};
int MySelect(node * head,node *temp) //返回查找到符合条件的项目数
{
int equal,N;
char CHAR[10];
printf("----------------------------------------------\n\n");
printf("查找模式:1是相等查找,0是不相等查找\n");
printf("列名编号:1是考号,2是姓名,3是语文成绩,4是数学成绩,5是英语成绩,6是总分\n");
printf("\n--------------------------------------------\n");
do
{
printf("\n选择查找模式:");
equal=getche();
if((equal!='1')&&(equal!='0'))
printf("\n\t输入错误\n");
}while((equal!='1')&&(equal!='0'));
equal=equal-48;
do
{
printf("\n输入列名编号:");
N=getche();
if(N!='1'&&N!='2'&&N!='3'&&N!='4'&&N!='5'&&N!='6')
printf("\n\t输入错误\n");
}while(N!='1'&&N!='2'&&N!='3'&&N!='4'&&N!='5'&&N!='6');
switch(N)
{
case '1': N=0;break;//N为字节数
case '2': N=9;break;
case '3': break;
case '4': break;
case '5': break;
case '6': break;
}
printf("\n输入关键字:");
scanf("%s",CHAR);
int i=0,flag;
node *p,*tp=temp;
p=head->next;
while (NULL!=p)
{
if(N==0||N==9)
{
flag=strcmp((char *)p+N,CHAR);//(char *)p+N为指针位置,比较每一条记录中的考号、姓名等数据是否与输入的关键字相同
if((abs(flag)+equal)==1)//当equal为1时是相等查找,为0时是不相等查找;当abs(flag)为0时,数据与关键字相同,若为1则不同
{
node *end;
end = (node *)malloc(sizeof(node));
tp->next=end;
tp=end;
tp->next=NULL;
tp->stu=p->stu;
if(i==0)
printf (PRINT_TITLE);
i++;
printf(PRINT_FORMAT);
}
p=p->next;
}
else
{
cout.precision(6);
if(N=='3')
{
flag=strcmp( (DoubleToString(p->stu.Chinese).c_str()),CHAR );
}
if(N=='4'){
flag=strcmp( (DoubleToString(p->stu.math).c_str()),CHAR );
}
if(N=='5'){
flag=strcmp( (DoubleToString(p->stu.English).c_str()),CHAR );
}
if(N=='6'){
flag=strcmp( (DoubleToString(p->stu.count_score).c_str()),CHAR );
}
if(flag==0)//当equal为1时是相等查找,为0时是不相等查找;当abs(flag)为0时,数据与关键字相同,若为1则不同
{
node *end;
end = (node *)malloc(sizeof(node));
tp->next=end;
tp=end;
tp->next=NULL;
tp->stu=p->stu;
if(i==0)
printf (PRINT_TITLE);
i++;
printf(PRINT_FORMAT);
}
p=p->next;
}
}
if(i==0)
printf("\n\t没有查找到符合条件的信息\n");
return i;
}
int SelectScore(node * head)
{
char CHAR[10];
printf("----------------------------------------------\n\n");
printf("请输入考号:\n");
scanf("%s",CHAR);
int i=0,flag;
node *p;
p=head->next;
while (NULL!=p)
{
flag=strcmp((char *)p,CHAR);//比较每一条记录中的考号是否与查询的考号相同
if(flag==0)
{
if(i==0)
printf (PRINT_TITLE);
i++;
printf(PRINT_FORMAT);
}
p=p->next;
}
if(i==0)
printf("\n\t没有查找到相应考号的信息\n");
return i;
}
void InsertSort(node *head)//总分从高到低排序
{
node *p,*q,*r,*u;
p=head->next;
head->next=NULL;
while(p!=NULL)
{
r=head;
q=head->next;
while(q!=NULL&&((q->stu.count_score)>(p->stu.count_score)))
{
r=q;
q=q->next;
}
u=p->next;
p->next=r->next;
r->next=p;
p=u;
}
}
void CheckNum(node *head)
{
/*删除学号重复的条目*/
node *release,*p;
p=head->next;
int m=0;
while(NULL!=p->next)
{
node *p2=p;
while(NULL!=p2->next)
{
if(0==strcmp(p->stu.num,p2->next->stu.num))
{ m++;
if(m==1)
printf("\t\t以下条目因考号与前面的信息冲突而没有导入\n");
printf("%s\t%s\t%lf\t%lf\t%lf\t%lf",p2->stu.num,p2->stu.name,p2->stu.Chinese,p2->stu.math,p2->stu.English,p2->stu.count_score);
release=p2->next;
p2->next=p2->next->next;
free(release);
}
p2=p2->next;
}
p=p->next;
}
}
void Fprintf(node *head)
{
char file[15]="student.txt";
FILE *fp;
if((fp=fopen(file,"w"))==NULL)
{
printf("\n\t文件打开失败,按任意键退出\n");
getch();
exit(0);
}
node *p=head->next;
while(NULL!=p)
{
if(p->next==NULL)//不要最后一行的回车,这样的话导入该文件时就不会有末尾的乱码
fprintf(fp,"%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score);
else
fprintf(fp,WRITE_FORMAT);
p=p->next;
}
fclose(fp);
}
void FscanfFromFile(node *head)
{
char file[20]="student1.txt";
FILE *fp;
if((fp=fopen(file,"r"))==NULL)
{
printf("\n\t文件打开失败,按任意键退出\n");
getch();
exit(0);
}
node *p=head;
while(!feof(fp))
{
node *end;
end = (node *)malloc(sizeof(node));
p->next=end;
p=end;
p->next=NULL;
fscanf(fp,READ_FORMAT);
}
printf("\n\t信息导入成功\n");
InsertSort(head);
Fprintf(head);
fclose(fp);
}
void ShowList(node *head)//带头结点的链表
{
InsertSort(head);
node *p=head->next;
int i=0;
printf ("\t\t\t成绩汇总排序表\n");
printf (PRINT_TITLE);
while(NULL!=p )
{ i++;
printf (PRINT_FORMAT);
p=p->next;
}
}
void FprintfToFile(node *head)
{
char file[15];
printf("\n输入要写入的文件名:");
scanf("%s",file);
FILE *fp;
if((fp=fopen(file,"w+"))==NULL)
{
printf("\n\t文件创建失败\n");
exit(0);
}
node *p=head->next;
while(NULL!=p)
{
if(p->next==NULL)//不要最后一行的回车,这样的话导入该文件时就不会有末尾的乱码
fprintf(fp,"%s\t%s\t%lf\t%lf\t%lf\t%lf",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score);
else
fprintf(fp,WRITE_FORMAT);
p=p->next;
}
fclose(fp);
printf("\n\t数据写入成功\n",file);//printf输出双引号要用转义字\"
}
node *ClearList(node *head)
{
node *p=head->next;
while(NULL!=p)
{
node *tp=p->next;
free(p);
p=tp;
}
return head->next=NULL;
}
int AddStu(node *head)
{
cout<<"共需输入多少位学生信息?"<<endl;
int i;
cin>>i;
int u=1;
do
{
node *p,*p2=head,*p3;
p=(node *)malloc(sizeof(node));
cout<<"请依次输入第"<<u<<"位学生的考号、姓名、语文成绩、数学成绩和英语成绩(用空格隔开):\n";
if(u>1)
{
cout<<" 按y继续添加,按其他键停止添加\n\n"<<endl;
char charget;
charget=getch();
if(charget=='y')
goto loop1;
else
break;
}
loop1:
cin>>p->stu.num>>p->stu.name>>p->stu.Chinese>>p->stu.math>>p->stu.English;
p->stu.count_score = p->stu.Chinese + p->stu.math + p->stu.English;
int flag=0;
p2=head;
while(NULL!=p2->next)
{ /*找出第一个比新学生的考号大的位置,将新信息放在它前面*/
if((flag=strcmp(p->stu.num,p2->next->stu.num))<0)
{
p3=p2->next;
p2->next=p;
p->next=p3;
break;
}
p2=p2->next;
}
/*如果新添加学生的考号比已有的都大,放置最末尾*/
if(flag>0)
{
p2->next=p;
p->next=NULL;
}
i--;
u++;
}while(i>0);
printf("信息添加成功\n");
printf("\t按任意键返回\n");
getch();
return 1;
}
int DeleteByNum(node *head)
{ char num[9];
int flag=1;
node *p=head,*p2;
printf("输入要删除信息的考号:");
scanf("%s",num);
while(NULL!=p->next)
{
if((flag=strcmp(p->next->stu.num,num))==0)
{
p2=p->next;
p->next=p->next->next;
free(p2);
printf("删除成功\n");
break;
}
p=p->next;
}
if(flag!=0)
printf("你输入的考号不存在\n");
printf("\t按任意键返回\n");
getche();
return 1;
}
int main()
{
node *head;
int i=0;
head = (node *)malloc(sizeof(node));
strcpy(head->stu.num," ");
strcpy(head->stu.name," ");
head->stu.Chinese=0;
head->stu.math=0;
head->stu.English=0;
head->stu.count_score=0;
node *temp= (node *)malloc(sizeof(node));//保存查找结果的头结点
printf("欢迎使用\n");
printf("\n----------------------------------------------\n");
FscanfFromFile(head);
char charget;
do
{
printf("\n----------------------------------------------\n");
printf("\n[1]信息显示\n");
printf("[2]信息查找\n");
printf("[3]查询成绩\n");
printf("[4]添加信息\n");
printf("[5]删除信息\n");
printf("[6]退出程序\n");
do
{
charget=getch();
}while((charget!='1')&&(charget!='2')&&(charget!='3')&&(charget!='4')&&(charget!='5')&&(charget!='6'));
switch(charget)
{
case '1': ShowList(head);
printf("\n按任意键显示上层操作菜单\n");
getch();
break;
case '2': if(0!=MySelect(head,temp))//查找结束不为空则进行下面的操作,为空则返回上层菜单
{
char charget2;
do
{
printf("\n[1]在此基础上继续查找\n");
printf("[2]将查找结果写入文件\n");
printf("[3]退出本次查找\n");
do
{
charget2=getch();
}while((charget2!='1')&&(charget2!='2')&&(charget2!='3'));
switch(charget2)
{
case '1': if(0==MySelect(temp,temp))
{
printf("\n按任意键结束本次查找\n");
getch();
charget2='3';
}
break;
case '2': FprintfToFile(temp);
charget2='3';//数据写入后,自动结束本次查找
break;
case '3': ClearList(temp);//结束查找,释放暂存查找结果的链表
break;
}//end switch,结束本次查找
}
while(charget2!='3');//如果charget2也用charget的话,在查找中按键3会直接退出程序
}//end if
break;
case '3': SelectScore(head);break;
case '4': AddStu(head);Fprintf(head);break;
case '5': DeleteByNum(head);Fprintf(head);break;
}//end switch,结束操作
}while(charget!='6');
return 0;
}
// DlgProxy.cpp : 实现文件
//
#include "stdafx.h"
#include "project2.h"
#include "DlgProxy.h"
#include "project2Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// Cproject2DlgAutoProxy
IMPLEMENT_DYNCREATE(Cproject2DlgAutoProxy, CCmdTarget)
Cproject2DlgAutoProxy::Cproject2DlgAutoProxy()
{
EnableAutomation();
// 为使应用程序在自动化对象处于活动状态时一直保持
// 运行,构造函数调用 AfxOleLockApp。
AfxOleLockApp();
// 通过应用程序的主窗口指针
// 来访问对话框。设置代理的内部指针
// 指向对话框,并设置对话框的后向指针指向
// 该代理。
ASSERT_VALID(AfxGetApp()->m_pMainWnd);
if (AfxGetApp()->m_pMainWnd)
{
ASSERT_KINDOF(Cproject2Dlg, AfxGetApp()->m_pMainWnd);
if (AfxGetApp()->m_pMainWnd->IsKindOf(RUNTIME_CLASS(Cproject2Dlg)))
{
m_pDialog = reinterpret_cast<Cproject2Dlg*>(AfxGetApp()->m_pMainWnd);
m_pDialog->m_pAutoProxy = this;
}
}
}
Cproject2DlgAutoProxy::~Cproject2DlgAutoProxy()
{
// 为了在用 OLE 自动化创建所有对象后终止应用程序,
// 析构函数调用 AfxOleUnlockApp。
// 除了做其他事情外,这还将销毁主对话框
if (m_pDialog != NULL)
m_pDialog->m_pAutoProxy = NULL;
AfxOleUnlockApp();
}
void Cproject2DlgAutoProxy::OnFinalRelease()
{
// 释放了对自动化对象的最后一个引用后,将调用
// OnFinalRelease。基类将自动
// 删除该对象。在调用该基类之前,请添加您的
// 对象所需的附加清理代码。
CCmdTarget::OnFinalRelease();
}
BEGIN_MESSAGE_MAP(Cproject2DlgAutoProxy, CCmdTarget)
END_MESSAGE_MAP()
BEGIN_DISPATCH_MAP(Cproject2DlgAutoProxy, CCmdTarget)
END_DISPATCH_MAP()
// 注意: 我们添加了对 IID_Iproject2 的支持
// 以支持来自 VBA 的类型安全绑定。此 IID 必须同附加到 .IDL 文件中的
// 调度接口的 GUID 匹配。
// {138BD86D-7208-4D55-92AF-7D388F8DB8CC}
static const IID IID_Iproject2 =
{ 0x138BD86D, 0x7208, 0x4D55, { 0x92, 0xAF, 0x7D, 0x38, 0x8F, 0x8D, 0xB8, 0xCC } };
BEGIN_INTERFACE_MAP(Cproject2DlgAutoProxy, CCmdTarget)
INTERFACE_PART(Cproject2DlgAutoProxy, IID_Iproject2, Dispatch)
END_INTERFACE_MAP()
// IMPLEMENT_OLECREATE2 宏在此项目的 StdAfx.h 中定义
// {4E19AEBB-D321-4A0B-B5B7-B9BE7E723ED4}
IMPLEMENT_OLECREATE2(Cproject2DlgAutoProxy, "project2.Application", 0x4e19aebb, 0xd321, 0x4a0b, 0xb5, 0xb7, 0xb9, 0xbe, 0x7e, 0x72, 0x3e, 0xd4)
// Cproject2DlgAutoProxy 消息处理程序
// DlgProxy.h: 头文件
//
#pragma once
class Cproject2Dlg;
// Cproject2DlgAutoProxy 命令目标
class Cproject2DlgAutoProxy : public CCmdTarget
{
DECLARE_DYNCREATE(Cproject2DlgAutoProxy)
Cproject2DlgAutoProxy(); // 动态创建所使用的受保护的构造函数
// 特性
public:
Cproject2Dlg* m_pDialog;
// 操作
public:
// 重写
public:
virtual void OnFinalRelease();
// 实现
protected:
virtual ~Cproject2DlgAutoProxy();
// 生成的消息映射函数
DECLARE_MESSAGE_MAP()
DECLARE_OLECREATE(Cproject2DlgAutoProxy)
// 生成的 OLE 调度映射函数
DECLARE_DISPATCH_MAP()
DECLARE_INTERFACE_MAP()
};
================================================================================
MICROSOFT 基础类库: project2 项目概述
===============================================================================
应用程序向导已为您创建了这个 project2 应用程序。此应用程序不仅演示 Microsoft 基础类的基本使用方法,还可作为您编写应用程序的起点。
本文件概要介绍组成 project2 应用程序的每个文件的内容。
project2.vcxproj
这是使用应用程序向导生成的 VC++ 项目的主项目文件。
它包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
project2.vcxproj.filters
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。
它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
project2.h
这是应用程序的主要头文件。它包括其他项目特定的头文件(包括 Resource.h),并声明 Cproject2App 应用程序类。
project2.cpp
这是包含应用程序类 Cproject2App 的主要应用程序源文件。
project2.rc
这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。此文件可以直接在 Microsoft Visual C++ 中进行编辑。项目资源位于 2052 中。
res\project2.ico
这是用作应用程序图标的图标文件。此图标包括在主要资源文件 project2.rc 中。
res\project2.rc2
此文件包含不在 Microsoft Visual C++ 中进行编辑的资源。您应该将不可由资源编辑器编辑的所有资源放在此文件中。
project2.reg
这是一个示例 .reg 文件,它显示了框架将为您设置的注册设置的种类。可以将它用作
将与您的应用程序一起使用的 .reg 文件。
project2.idl
此文件包含应用程序类型库的接口描述语言源代码。
/////////////////////////////////////////////////////////////////////////////
应用程序向导创建一个对话框类和自动化代理类:
project2Dlg.h,project2Dlg.cpp - 对话框
这些文件包含 Cproject2Dlg 类。该类定义应用程序主对话框的行为。该对话框的模板位于 project2.rc 中,该文件可以在 Microsoft Visual C++ 中进行编辑。
DlgProxy.h,DlgProxy.cpp - 自动化对象
这些文件包含 Cproject2DlgAutoProxy 类。此类称为对话框的自动化代理类,这是因为它负责公开自动化控制器可以用来访问对话框的自动化方法和属性。这些方法和属性不是从对话框类直接公开的,因为在基于模式对话框的 MFC 应用程序中,能够更清楚、更容易地将自动化对象与用户界面分离。
/////////////////////////////////////////////////////////////////////////////
其他功能:
ActiveX 控件
应用程序包括对使用 ActiveX 控件的支持。
/////////////////////////////////////////////////////////////////////////////
其他标准文件:
StdAfx.h,StdAfx.cpp
这些文件用于生成名为 project2.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
Resource.h
这是标准头文件,它定义新的资源 ID。
Microsoft Visual C++ 读取并更新此文件。
project2.manifest
应用程序清单文件供 Windows XP 用来描述应用程序
对特定版本并行程序集的依赖性。加载程序使用此
信息从程序集缓存加载适当的程序集或
从应用程序加载私有信息。应用程序清单可能为了重新分发而作为
与应用程序可执行文件安装在相同文件夹中的外部 .manifest 文件包括,
也可能以资源的形式包括在该可执行文件中。
/////////////////////////////////////////////////////////////////////////////
其他注释:
应用程序向导使用“TODO:”指示应添加或自定义的源代码部分。
如果应用程序在共享的 DLL 中使用 MFC,则需要重新发布这些 MFC DLL;如果应用程序所用的语言与操作系统的当前区域设置不同,则还需要重新发布对应的本地化资源 MFC100XXX.DLL。有关这两个主题的更多信息,请参见 MSDN 文档中有关 Redistributing Visual C++ applications (重新发布 Visual C++ 应用程序)的章节。
/////////////////////////////////////////////////////////////////////////////
// first.cpp : 实现文件
//
#include "stdafx.h"
#include "project2.h"
#include "first.h"
#include "afxdialogex.h"
#include <iostream>
#include <stdio.h>
#include<fstream>
#include <malloc.h>
#include <conio.h>
#include <stdlib.h>
#include <cstdlib>
#include <string>
#include <math.h>
using namespace std;
#define CLRSCR system("cls")
#define PRINT_TITLE "\n序号\t考号\t\t姓名\t语文\t数学\t英语\t总分\n"
#define PRINT_FORMAT "%d\t%s\t%s\t%d\t%d\t%d\t%d\n",i,p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score
#define WRITE_FORMAT "%s\t%s\t%d\t%d\t%d\t%d\n",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score
#define READ_FORMAT "%s %s %d %d %d %d",&p->stu.num,&p->stu.name,&p->stu.Chinese,&p->stu.math,&p->stu.English,&p->stu.count_score
// first 对话框
IMPLEMENT_DYNAMIC(first, CDialogEx)
first::first(CWnd* pParent /*=NULL*/)
: CDialogEx(first::IDD, pParent)
, m_value10(_T(""))
{
}
first::~first()
{
}
void first::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_value10);
}
BEGIN_MESSAGE_MAP(first, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON1, &first::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON2, &first::OnBnClickedButton2)
END_MESSAGE_MAP()
// first 消息处理程序
//定义学生类
class student_bx
{
public:
char num[40];
char name[20];//三个汉字长度为6个字节,应多定义一个字节来存放字符串结束符'\0'
int Chinese;
int math;
int English;
int count_score;
};
//定义单链表类
class node
{
public:
student_bx stu;
node *next;
};
int MySelect(node * head,node *temp)
{
int i=0;
node *p,*tp=temp;
p=head->next;
FILE *fp;
char file[15]="f:\\English.txt";
if((fp=fopen(file,"w+"))==NULL)
{
printf("\n\t文件创建失败\n");
exit(0);
}
while (NULL!=p)
{
if(p->stu.English>100&&p->stu.count_score>300)
{
node *end;
end = (node *)malloc(sizeof(node));
tp->next=end;
tp=end;
tp->next=NULL;
tp->stu=p->stu;
if(i==0)
printf (PRINT_TITLE);
i++;
printf(PRINT_FORMAT);
if(p->next==NULL)//不要最后一行的回车,这样的话导入该文件时就不会有末尾的乱码
fprintf(fp,"%s\t%s\t%d\t%d\t%d\t%d",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score);
else
fprintf(fp,WRITE_FORMAT);
}
p=p->next;
}
fclose(fp);
if(i==0)
printf("\n\t英语超过100分且总分成绩超过300分的学生人数为零\n");
return i;
}
void Fprintf(node *head)
{
char file[40]={"f:\\boxiang_stu.txt"};
FILE *fp;
if((fp=fopen(file,"w"))==NULL)
{
printf("\n\t文件打开失败,按任意键退出\n");
getch();
exit(0);
}
node *p=head->next;
while(NULL!=p)
{
if(p->next==NULL)//不要最后一行的回车,这样的话导入该文件时就不会有末尾的乱码
fprintf(fp,"%s\t%s\t%d\t%d\t%d\t%d",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score);
else
fprintf(fp,WRITE_FORMAT);
p=p->next;
}
fclose(fp);
}
void InsertSort(node *head)//总分从大到小排序
{
node *p,*q,*u,*h,*w,*n;
int j=0;
p=head->next;
while(p!=NULL)
{
j++;
p=p->next;
}
for(int i=0;i<j-1;i++)
{
p=head;
q=p->next;
for(int z=0;z<=j-2-i;z++)
{
int y=0;
if((q->next->stu.count_score)>(p->next->stu.count_score))
{
n=q->next;
u=n->next;
w=p->next;
p->next=n;
n->next=w;
q->next=u;
p=p->next;
y=1;
}
if(y==0)
{
p=p->next;
q=q->next;
}
}
}
}
void FscanfFromFile(node *head)//cdsgfdgfhhhhhhhhhhhhhhhhhhhhhhh
{
char file[20]="f:\\student1.txt";
char file2[20]="f:\\student2.txt";
FILE *fp,*fp2;
if((fp=fopen(file,"r"))==NULL)
{
printf("\n\t文件打开失败,按任意键退出\n");
getch();
exit(0);
}
if((fp2=fopen(file2,"r"))==NULL)
{
printf("\n\t文件打开失败,按任意键退出\n");
getch();
exit(0);
}
node *p=head;
while(!feof(fp))
{
node *end;
end = (node *)malloc(sizeof(node));
p->next=end;
p=end;
p->next=NULL;
fscanf(fp,READ_FORMAT);
}
while(!feof(fp2))
{
node *end;
end = (node *)malloc(sizeof(node));
p->next=end;
p=end;
p->next=NULL;
fscanf(fp2,READ_FORMAT);
}
printf("\n\t信息导入成功\n");
InsertSort(head);
Fprintf(head);
fclose(fp);
}
void ShowList(node *head)//带头结点的链表
{
node *p=head->next;
int i=0;
printf ("\t\t\t成绩汇总排序表\n");
printf (PRINT_TITLE);
while(NULL!=p )
{ i++;
printf (PRINT_FORMAT);
p=p->next;
}
}
void FprintfToFile(node *head)
{
char file[50]={"f:\\boxiang_stu.txt"};
//printf("\n输入要写入的文件名:");
//scanf("%s",file);
FILE *fp;
if((fp=fopen(file,"w+"))==NULL)
{
printf("\n\t文件创建失败\n");
exit(0);
}
node *p=head->next;
while(NULL!=p)
{
if(p->next==NULL)//不要最后一行的回车,这样的话导入该文件时就不会有末尾的乱码
fprintf(fp,"%s\t%s\t%d\t%d\t%d\t%d",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score);
else
fprintf(fp,WRITE_FORMAT);
p=p->next;
}
fclose(fp);
printf("\n\t数据写入成功\n",file);//printf输出双引号要用转义字\"
}
node *ClearList(node *head)
{
node *p=head->next;
while(NULL!=p)
{
node *tp=p->next;
free(p);
p=tp;
}
return head->next=NULL;
}
void first::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
node *head;
int i=0;
head = (node *)malloc(sizeof(node));
strcpy(head->stu.num," ");
strcpy(head->stu.name," ");
head->stu.Chinese=0;
head->stu.math=0;
head->stu.English=0;
head->stu.count_score=0;
node *temp= (node *)malloc(sizeof(node));//保存查找结果的头结点
FscanfFromFile(head);
ShowList(head);
ifstream in;
string str,str2;
m_value10="";
in.open("f:\\boxiang_stu.txt",ios::in);
while(!in.eof())
{
getline(in,str,'\n');
str2+=str+"\r\n";
CString cstr(str2.c_str());
cstr=str2.c_str();
m_value10=cstr;
}
UpdateData(FALSE);
}
void first::OnBnClickedButton2()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
node *head;
int i=0;
head = (node *)malloc(sizeof(node));
strcpy(head->stu.num," ");
strcpy(head->stu.name," ");
head->stu.Chinese=0;
head->stu.math=0;
head->stu.English=0;
head->stu.count_score=0;
node *temp= (node *)malloc(sizeof(node));//保存查找结果的头结点
FscanfFromFile(head);
MySelect(head,temp);
ifstream in;
m_value10="";
string str="",str2="";
in.open("f:\\English.txt",ios::in);
while(!in.eof())
{
getline(in,str,'\n');
str2+=str+"\r\n";
CString cstr(str2.c_str());
cstr=str2.c_str();
m_value10=cstr;
}
UpdateData(FALSE);
}
#pragma once
// first 对话框
class first : public CDialogEx
{
DECLARE_DYNAMIC(first)
public:
first(CWnd* pParent = NULL); // 标准构造函数
virtual ~first();
// 对话框数据
enum { IDD = IDD_DIALOG1 };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButton1();
CString m_value10;
afx_msg void OnBnClickedButton2();
};
// five.cpp : 实现文件
//
#include "stdafx.h"
#include "project2.h"
#include "five.h"
#include "afxdialogex.h"
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
// five 对话框
IMPLEMENT_DYNAMIC(five, CDialogEx)
five::five(CWnd* pParent /*=NULL*/)
: CDialogEx(five::IDD, pParent)
, m_count1(0)
, m_count2(0)
, m_count3(0)
, m_count4(0)
, m_count5(0)
, m_x(0)
, m_y(0)
, m_width(0)
, m_height(0)
, m_n1(0)
, m_n2(0)
, m_n3(0)
, m_n4(0)
, m_n5(0)
, m_sum1(0)
, m_sum2(0)
, m_sum3(0)
, m_sum4(0)
, m_sum5(0)
, m_sum(0)
, m_height0(0)
, m_height2(0)
, m_height3(0)
, m_height4(0)
, m_height5(0)
, m_scroe(0)
{
}
five::~five()
{
}
void five::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_count1);
DDX_Text(pDX, IDC_EDIT2, m_count2);
DDX_Text(pDX, IDC_EDIT3, m_count3);
DDX_Text(pDX, IDC_EDIT4, m_count4);
DDX_Text(pDX, IDC_EDIT5, m_count5);
DDX_Text(pDX, IDC_EDIT6, m_scroe);
}
BEGIN_MESSAGE_MAP(five, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON1, &five::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON2, &five::OnBnClickedButton2)
ON_BN_CLICKED(IDC_BUTTON3, &five::OnBnClickedButton3)
ON_BN_CLICKED(IDC_BUTTON4, &five::OnBnClickedButton4)
END_MESSAGE_MAP()
// five 消息处理程序
void five::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
///UpdateData(TRUE);
ifstream in,in2;
string num;
string name;
string sex;
int age;
string address;
double chinese;
double math;
double english;
double history;
double art;
double geograpy;
double physics;
double sum;
string category;
string subject;
m_n1=m_n2=m_n3=m_n4=m_n5=0.0;
m_sum1=m_sum2=m_sum3=m_sum4=m_sum5=0.0;
in.open("f:\\student_bo.txt",ios::in);
in2.open("f:\\student_bo.txt",ios::in);
while(!in.eof())
{
in>>num>>name>>sex>>age>>address>>category>>
chinese>>math
>>english>>history>>geograpy>>sum;
if((address=="湛江")&&(category=="理科"))
{
m_sum1++;
}
else if((address=="广州")&&(category=="理科"))
{
m_sum2++;
}
else if((address=="珠海")&&(category=="理科"))
{
m_sum3++;
}
else if((address=="汕头")&&(category=="理科"))
{
m_sum4++;
}
else if((address=="深圳")&&(category=="理科"))
{
m_sum5++;
}
}
while(!in2.eof())
{
in2>>num>>name>>sex>>age>>address>>category>>
chinese>>math
>>english>>history>>geograpy>>sum;
if((sum>=m_scroe))
{
// cout<<num<<" "<<name<<" "<<sex<<" "<<age<<" "<<address<<" "<<category<<
// " "<<chinese<<" "<<math
// <<" "<<english<<" "<<history<<" "<<geograpy<<" "<<sum<<endl;
if((address=="湛江")&&(category=="理科"))
{
m_n1++;
}
else if((address=="广州")&&(category=="理科"))
{
m_n2++;
}
else if((address=="珠海")&&(category=="理科"))
{
m_n3++;
}
else if((address=="汕头")&&(category=="理科"))
{
m_n4++;
}
else if((address=="深圳")&&(category=="理科"))
{
m_n5++;
}
}
}
//int width;
GetDlgItem(IDC_IMG)->ShowWindow(TRUE);
GetDlgItem(IDC_IMG3)->ShowWindow(TRUE);
GetDlgItem(IDC_IMG4)->ShowWindow(TRUE);
GetDlgItem(IDC_IMG5)->ShowWindow(TRUE);
GetDlgItem(IDC_IMG6)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT1)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT2)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT3)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT4)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT5)->ShowWindow(TRUE);
m_height0=600.0;//总高度
m_count1=m_n1;
m_count2=m_n2;
m_count3=m_n3;
m_count4=m_n4;
m_count5=m_n5;
//m_count1=m_sum1+m_sum2+m_sum3+m_sum4+m_sum5;
m_sum=100;
//m_sum1+m_sum2+m_sum3+m_sum4+m_sum5;
m_height=(m_n1/m_sum)*m_height0;
m_height2=(m_n2/m_sum)*m_height0;
m_height3=(m_n3/m_sum)*m_height0;
m_height4=(m_n4/m_sum)*m_height0;
m_height5=(m_n5/m_sum)*m_height0;
//GetDlgItem (IDC_IMG)->GetWindow(width);
//m_width=width;
//GetDlgItem(IDC_BUTTON1)->MoveWindow( x, y, width, height );
GetDlgItem(IDC_IMG)->MoveWindow( 120,(m_height0-150-m_height), 40, m_height );
GetDlgItem(IDC_IMG3)->MoveWindow( 170,(m_height0-150-m_height2), 40, m_height2 );
GetDlgItem(IDC_IMG4)->MoveWindow( 220,(m_height0-150-m_height3), 40, m_height3 );
GetDlgItem(IDC_IMG5)->MoveWindow( 270,(m_height0-150-m_height4), 40, m_height4 );
GetDlgItem(IDC_IMG6)->MoveWindow( 320,(m_height0-150-m_height5), 40, m_height5 );
GetDlgItem(IDC_EDIT1)->MoveWindow( 120,(m_height0-m_height-175.0), 30, 20 );
GetDlgItem(IDC_EDIT2)->MoveWindow( 170,(m_height0-m_height2-175.0), 30, 20 );
GetDlgItem(IDC_EDIT3)->MoveWindow( 220,(m_height0-m_height3-175.0), 30, 20 );
GetDlgItem(IDC_EDIT4)->MoveWindow( 270,(m_height0-m_height4-175.0), 30, 20 );
GetDlgItem(IDC_EDIT5)->MoveWindow( 320,(m_height0-m_height5-175.0), 30, 20 );
// CRect rect;
// GetDlgItem(IDC_IMG)->GetWindowRect(&rect);
/// m_width=rect.Width();
// m_height=rect.Height();
UpdateData(FALSE);
}
void five::OnBnClickedButton2()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
///UpdateData(TRUE);
ifstream in,in2;
string num;
string name;
string sex;
int age;
string address;
double chinese;
double math;
double english;
double history;
double art;
double geograpy;
double physics;
double sum;
string category;
string subject;
m_n1=m_n2=m_n3=m_n4=m_n5=0;
m_sum1=m_sum2=m_sum3=m_sum4=m_sum5=0;
in.open("f:\\student_bo.txt",ios::in);
in2.open("f:\\student_bo.txt",ios::in);
while(!in.eof())
{
in>>num>>name>>sex>>age>>address>>category>>
chinese>>math
>>english>>history>>geograpy>>sum;
if((address=="湛江")&&(category=="文科"))
{
m_sum1++;
}
else if((address=="广州")&&(category=="文科"))
{
m_sum2++;
}
else if((address=="珠海")&&(category=="文科"))
{
m_sum3++;
}
else if((address=="汕头")&&(category=="文科"))
{
m_sum4++;
}
else if((address=="深圳")&&(category=="文科"))
{
m_sum5++;
}
}
while(!in2.eof())
{
in2>>num>>name>>sex>>age>>address>>category>>
chinese>>math
>>english>>history>>geograpy>>sum;
if((sum>=m_scroe))
{
// cout<<num<<" "<<name<<" "<<sex<<" "<<age<<" "<<address<<" "<<category<<
// " "<<chinese<<" "<<math
// <<" "<<english<<" "<<history<<" "<<geograpy<<" "<<sum<<endl;
if((address=="湛江")&&(category=="文科"))
{
m_n1++;
}
else if((address=="广州")&&(category=="文科"))
{
m_n2++;
}
else if((address=="珠海")&&(category=="文科"))
{
m_n3++;
}
else if((address=="汕头")&&(category=="文科"))
{
m_n4++;
}
else if((address=="深圳")&&(category=="文科"))
{
m_n5++;
}
}
}
//int width;
GetDlgItem(IDC_IMG)->ShowWindow(TRUE);
GetDlgItem(IDC_IMG3)->ShowWindow(TRUE);
GetDlgItem(IDC_IMG4)->ShowWindow(TRUE);
GetDlgItem(IDC_IMG5)->ShowWindow(TRUE);
GetDlgItem(IDC_IMG6)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT1)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT2)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT3)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT4)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT5)->ShowWindow(TRUE);
m_height0=600;//总高度
m_count1=m_n1;
m_count2=m_n2;
m_count3=m_n3;
m_count4=m_n4;
m_count5=m_n5;
//m_count1=m_sum1+m_sum2+m_sum3+m_sum4+m_sum5;
m_sum=100;
//m_sum1+m_sum2+m_sum3+m_sum4+m_sum5;
m_height=(m_n1/m_sum)*m_height0;
m_height2=(m_n2/m_sum)*m_height0;
m_height3=(m_n3/m_sum)*m_height0;
m_height4=(m_n4/m_sum)*m_height0;
m_height5=(m_n5/m_sum)*m_height0;
//GetDlgItem (IDC_IMG)->GetWindow(width);
//m_width=width;
//GetDlgItem(IDC_BUTTON1)->MoveWindow( x, y, width, height );
GetDlgItem(IDC_IMG)->MoveWindow( 120,(m_height0-150-m_height), 40, m_height );
GetDlgItem(IDC_IMG3)->MoveWindow( 170,(m_height0-150-m_height2), 40, m_height2 );
GetDlgItem(IDC_IMG4)->MoveWindow( 220,(m_height0-150-m_height3), 40, m_height3 );
GetDlgItem(IDC_IMG5)->MoveWindow( 270,(m_height0-150-m_height4), 40, m_height4 );
GetDlgItem(IDC_IMG6)->MoveWindow( 320,(m_height0-150-m_height5), 40, m_height5 );
GetDlgItem(IDC_EDIT1)->MoveWindow( 120,(m_height0-m_height-175), 30, 20 );
GetDlgItem(IDC_EDIT2)->MoveWindow( 170,(m_height0-m_height2-175), 30, 20 );
GetDlgItem(IDC_EDIT3)->MoveWindow( 220,(m_height0-m_height3-175), 30, 20 );
GetDlgItem(IDC_EDIT4)->MoveWindow( 270,(m_height0-m_height4-175), 30, 20 );
GetDlgItem(IDC_EDIT5)->MoveWindow( 320,(m_height0-m_height5-175), 30, 20 );
// CRect rect;
// GetDlgItem(IDC_IMG)->GetWindowRect(&rect);
/// m_width=rect.Width();
// m_height=rect.Height();
UpdateData(FALSE);
}
void five::OnBnClickedButton3()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
///UpdateData(TRUE);
ifstream in,in2;
string num;
string name;
string sex;
int age;
string address;
double chinese;
double math;
double english;
double history;
double art;
double geograpy;
double physics;
double sum;
string category;
string subject;
m_n1=m_n2=m_n3=m_n4=m_n5=0;
m_sum1=m_sum2=m_sum3=m_sum4=m_sum5=0;
in.open("f:\\student_bo.txt",ios::in);
in2.open("f:\\student_bo.txt",ios::in);
while(!in.eof())
{
in>>num>>name>>sex>>age>>address>>category>>
chinese>>math
>>english>>history>>geograpy>>sum;
if((address=="湛江")&&(category=="艺术"))
{
m_sum1++;
}
else if((address=="广州")&&(category=="艺术"))
{
m_sum2++;
}
else if((address=="珠海")&&(category=="艺术"))
{
m_sum3++;
}
else if((address=="汕头")&&(category=="艺术"))
{
m_sum4++;
}
else if((address=="深圳")&&(category=="艺术"))
{
m_sum5++;
}
}
while(!in2.eof())
{
in2>>num>>name>>sex>>age>>address>>category>>
chinese>>math
>>english>>history>>geograpy>>sum;
if((sum>=m_scroe))
{
// cout<<num<<" "<<name<<" "<<sex<<" "<<age<<" "<<address<<" "<<category<<
// " "<<chinese<<" "<<math
// <<" "<<english<<" "<<history<<" "<<geograpy<<" "<<sum<<endl;
if((address=="湛江")&&(category=="艺术"))
{
m_n1++;
}
else if((address=="广州")&&(category=="艺术"))
{
m_n2++;
}
else if((address=="珠海")&&(category=="艺术"))
{
m_n3++;
}
else if((address=="汕头")&&(category=="艺术"))
{
m_n4++;
}
else if((address=="深圳")&&(category=="艺术"))
{
m_n5++;
}
}
}
//int width;
GetDlgItem(IDC_IMG)->ShowWindow(TRUE);
GetDlgItem(IDC_IMG3)->ShowWindow(TRUE);
GetDlgItem(IDC_IMG4)->ShowWindow(TRUE);
GetDlgItem(IDC_IMG5)->ShowWindow(TRUE);
GetDlgItem(IDC_IMG6)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT1)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT2)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT3)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT4)->ShowWindow(TRUE);
GetDlgItem(IDC_EDIT5)->ShowWindow(TRUE);
m_height0=600;//总高度
m_count1=m_n1;
m_count2=m_n2;
m_count3=m_n3;
m_count4=m_n4;
m_count5=m_n5;
//m_count1=m_sum1+m_sum2+m_sum3+m_sum4+m_sum5;
m_sum=100;
//m_sum1+m_sum2+m_sum3+m_sum4+m_sum5;
m_height=(m_n1/m_sum)*m_height0;
m_height2=(m_n2/m_sum)*m_height0;
m_height3=(m_n3/m_sum)*m_height0;
m_height4=(m_n4/m_sum)*m_height0;
m_height5=(m_n5/m_sum)*m_height0;
//GetDlgItem (IDC_IMG)->GetWindow(width);
//m_width=width;
//GetDlgItem(IDC_BUTTON1)->MoveWindow( x, y, width, height );
GetDlgItem(IDC_IMG)->MoveWindow( 120,(m_height0-150-m_height), 40, m_height );
GetDlgItem(IDC_IMG3)->MoveWindow( 170,(m_height0-150-m_height2), 40, m_height2 );
GetDlgItem(IDC_IMG4)->MoveWindow( 220,(m_height0-150-m_height3), 40, m_height3 );
GetDlgItem(IDC_IMG5)->MoveWindow( 270,(m_height0-150-m_height4), 40, m_height4 );
GetDlgItem(IDC_IMG6)->MoveWindow( 320,(m_height0-150-m_height5), 40, m_height5 );
GetDlgItem(IDC_EDIT1)->MoveWindow( 120,(m_height0-m_height-175), 30, 20 );
GetDlgItem(IDC_EDIT2)->MoveWindow( 170,(m_height0-m_height2-175), 30, 20 );
GetDlgItem(IDC_EDIT3)->MoveWindow( 220,(m_height0-m_height3-175), 30, 20 );
GetDlgItem(IDC_EDIT4)->MoveWindow( 270,(m_height0-m_height4-175), 30, 20 );
GetDlgItem(IDC_EDIT5)->MoveWindow( 320,(m_height0-m_height5-175), 30, 20 );
UpdateData(FALSE);
}
void five::OnBnClickedButton4()
{
// TODO: 在此添加控件通知处理程序代码
exit(0);
}
# Microsoft Developer Studio Project File - Name="five" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=five - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "five.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "five.mak" CFG="five - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "five - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "five - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "five - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x804 /d "NDEBUG"
# ADD RSC /l 0x804 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "five - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x804 /d "_DEBUG"
# ADD RSC /l 0x804 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "five - Win32 Release"
# Name "five - Win32 Debug"
# Begin Source File
SOURCE=.\five.cpp
# End Source File
# End Target
# End Project
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "five"=".\five.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
#pragma once
// five 对话框
class five : public CDialogEx
{
DECLARE_DYNAMIC(five)
public:
five(CWnd* pParent = NULL); // 标准构造函数
virtual ~five();
// 对话框数据
enum { IDD = IDD_DIALOG7 };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButton1();
double m_count1;
double m_count2;
double m_count3;
double m_count4;
double m_count5;
double m_x;
double m_y;
double m_width;
double m_height;
double m_n1;
double m_n2;
double m_n3;
double m_n4;
double m_n5;
double m_sum1;
double m_sum2;
double m_sum3;
double m_sum4;
double m_sum5;
double m_sum;
double m_height0;
double m_height2;
double m_height3;
double m_height4;
double m_height5;
afx_msg void OnBnClickedButton2();
afx_msg void OnBnClickedButton3();
afx_msg void OnBnClickedButton4();
int m_scroe;
};
文件已添加
文件已添加
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: five - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP1E.tmp" with contents
[
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/five.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"C:\Documents and Settings\Administrator\桌面\高考预录数据信息管理系统\project2\five.cpp"
]
Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP1E.tmp"
Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP1F.tmp" with contents
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/five.pdb" /debug /machine:I386 /out:"Debug/five.exe" /pdbtype:sept
".\Debug\five.obj"
]
Creating command line "link.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP1F.tmp"
<h3>Output Window</h3>
Compiling...
five.cpp
c:\documents and settings\administrator\桌面\高考预录数据信息管理系统\project2\targetver.h(8) : fatal error C1083: Cannot open include file: 'SDKDDKVer.h': No such file or directory
Error executing cl.exe.
<h3>Results</h3>
five.exe - 1 error(s), 0 warning(s)
</pre>
</body>
</html>
// four.cpp : 实现文件
//
#include "stdafx.h"
#include "project2.h"
#include "four.h"
#include "afxdialogex.h"
#include<iostream>
#include<string>
#include<fstream> //文件操作头文件
#include<vector> //容器头文件
#include <algorithm> //容器排序所用头文件
#include <functional>//容器排序所用头文件
using namespace std;
/*using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::fstream;
using std::vector;
using std::sort;
using std::greater; //容器排序的时候会用到
using std::less; */ //容器排序的时候会用到
string BOOL_GRADE;
int BOOL_TYPE[3]={0, 0, 0}; //开关
int BOOL_PLACE[5]={0, 0, 0, 0, 0};//开关
int BOOL_S[4]={ 0, 0, 0, 0 }; //开关
int BOOL_T[6]={ 0, 0, 0, 0, 0, 0 }; //开关
// four 对话框
IMPLEMENT_DYNAMIC(four, CDialogEx)
four::four(CWnd* pParent /*=NULL*/)
: CDialogEx(four::IDD, pParent)
, m_seek1(_T(""))
, m_value2(_T(""))
{
}
four::~four()
{
}
void four::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_seek1);
DDX_Text(pDX, IDC_EDIT2, m_value2);
}
BEGIN_MESSAGE_MAP(four, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON1, &four::OnBnClickedButton1)
END_MESSAGE_MAP()
// four 消息处理程序
class Student_yong2 //学生类
{
public:
Student_yong2 ();
~Student_yong2 ();
int finput(fstream *fp); //文件输入数据
void fdisplay(ofstream *fp); //文件输入数据
void input(); //控制台输入数据
void display(); //控制台输出数据
void setMath(); //设定数学成绩
void setChinese(); //设定语文成绩
void setEnglish(); //设定英语成绩
void getMath(); //获取数学成绩
void getChinese(); //获取语文成绩
void getEnglish(); //获取英语成绩
string _num; //考号
string _name; //姓名
string _sex; //性别
unsigned int _age; //年龄
string _place; //地点
string _type; //考生类型
string _wchar[5]; //储存前缀
unsigned int _chinese; //语文
unsigned int _math; //数学
unsigned int _English; //英语
unsigned int _course1; //课程一
unsigned int _course2; //课程二
unsigned int _sum; //总成绩
unsigned int _list_num; //序号
fstream *_fp; //文件指针
};
/*----------------------排序规则------------------------------*/
//总分降序排序
bool greatersum(const Student_yong2 & s1, const Student_yong2 & s2)
{
return s1._sum > s2._sum;
}
//英语成绩降序排序
bool greaterEnglish(const Student_yong2 & s1, const Student_yong2 & s2)
{
return s1._English > s2._English;
}
//语文成绩降序排序
bool greaterchinese(const Student_yong2 & s1, const Student_yong2& s2)
{
return s1._chinese > s2._chinese;
}
//数学成绩降序排序
bool greatermath(const Student_yong2 & s1, const Student_yong2 & s2)
{
return s1._math > s2._math;
}
//第一科降序排序
bool greatercourse1(const Student_yong2 & s1, const Student_yong2 & s2)
{
return s1._course1 > s2._course1;
}
//第二科降序排序
bool greatercourse2(const Student_yong2 & s1, const Student_yong2 & s2)
{
return s1._course2 > s2._course2;
}
/*-------------------------排序规则--------------------------*/
Student_yong2 ::Student_yong2 ()
{
_fp = 0; //初始化文件指针
}
Student_yong2 ::~Student_yong2 ()
{
}
int Student_yong2 ::finput(fstream *fp) //具体化finput()
{
_fp = fp;
(*_fp) >> _num >> _name //设定学号姓名
>> _sex >> _age //设定性别和年龄
>> _place >> _type //地点和考生类型
>> _wchar[0] >> _chinese >> _wchar[1] >> _math >> _wchar[2] >> _English; //设定3科成绩
if (_type == "文科")
{
(*_fp) >> _wchar[3] >> _course1 >> _wchar[4] >> _course2; //设定历史和地理
}
else
{
(*_fp) >> _wchar[3] >> _course1; //设定物理或美术
}
if (_num == "" || _name == "") //如果没有读到数据返回false
{
return 0;
}
else
{
//计算总成绩
_sum = _math + _English + _chinese + _course1 + _course2;
return 1;
}
}
void Student_yong2 ::fdisplay(ofstream *fp) //具体化display(调试的时候写的)
{
if (BOOL_S[0])
{
(*fp) << _num << " ";
}
if (BOOL_S[1])
{
(*fp) << _name << " ";
}
if (BOOL_S[2])
{
(*fp) << _sex << " ";
}
if (BOOL_S[3])
{
(*fp) << _age << " ";
}
if (BOOL_T[0])
{
(*fp) << _wchar[0] << " " << _chinese << " ";
}
if (BOOL_T[1])
{
(*fp) << _wchar[1] << " " << _math << " ";
}
if (BOOL_T[2])
{
(*fp) << _wchar[2] << " " << _English << " ";
}
if (BOOL_T[3])
{
(*fp) << _wchar[3] << " " << _course1 << " ";
}
if (BOOL_T[4] && _type == "文科")
{
(*fp) << _wchar[4] << " " << _course2 << " ";
}
if (BOOL_T[5])
{
(*fp) << "总分 " << _sum << " ";
}
(*fp) << endl;
// fp->close();//关闭文件
}
void Student_yong2 ::display() //具体化display(调试的时候写的)
{
if (BOOL_S[0])
{
cout << _num << " ";
}
if (BOOL_S[1])
{
cout << _name << " ";
}
if (BOOL_S[2])
{
cout << _sex << " ";
}
if (BOOL_S[3])
{
cout << _age << " ";
}
if (BOOL_T[0])
{
cout << _wchar[0] << " " << _chinese << " ";
}
if (BOOL_T[1])
{
cout << _wchar[1] << " " << _math << " ";
}
if (BOOL_T[2])
{
cout << _wchar[2] << " " << _English << " ";
}
if (BOOL_T[3])
{
cout << _wchar[3] << " " << _course1 << " ";
}
if (BOOL_T[4] && _type == "文科")
{
cout << _wchar[4] << " " << _course2 << " ";
}
if (BOOL_T[5])
{
cout << "总分 " << _sum << " ";
}
cout << endl;
}
/* 字符串处理 ,根据符号分类添加到容器 */
vector<string> splitEx(const string& src, string separate_character)
{
vector<string> strs;
int separate_characterLen = separate_character.size();//分割字符串的长度,这样就可以支持如“,,”多字符串的分隔符
int lastPosition = 0, index = -1;
while (-1 != (index = src.find(separate_character, lastPosition)))
{
strs.push_back(src.substr(lastPosition, index - lastPosition));
lastPosition = index + separate_characterLen;
}
string lastString = src.substr(lastPosition);//截取最后一个分隔符后的内容
if (!lastString.empty())
strs.push_back(lastString);//如果最后一个分隔符后还有内容就入队
return strs;
}
void four::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
fstream file_one("F://data_student.txt"); //打开第一个文件
if (!file_one) //如果打开失败
{
cout << "open error!" << endl;//显示出错信息
//abort();//程序退出
}
vector<Student_yong2 >stu_data; //定义一个空的stu_date容器,储存文件的全部信息
do
{
Student_yong2 stu;
if (stu.finput(&file_one)) //调用finpu(),输入成绩
{
stu_data.push_back(stu); //添加对象到容器末端
}
else
{
file_one.close(); //关闭文件
break; //跳出循环
}
} while (true);
vector<Student_yong2 >data_two[5]; //定义一个容器数组
//遍历stu_data
for (auto it = stu_data.begin(); it != stu_data.end(); ++it)
{
if ((*it)._place == "广州")
{
data_two[0].push_back(*it); //添加到data_two[0]
}
else if ((*it)._place == "汕头")
{
data_two[1].push_back(*it); //添加到data_two[1]
}
else if ((*it)._place == "珠海")
{
data_two[2].push_back(*it); //添加到data_two[2]
}
else if ((*it)._place == "湛江")
{
data_two[3].push_back(*it); //添加到data_two[3]
}
else if ((*it)._place == "深圳")
{
data_two[4].push_back(*it); //添加到data_two[4]
}
}
vector<Student_yong2>data_three[5][3];
for (size_t i = 0; i < 5; ++i)
{
for (auto it = data_two[i].begin(); it != data_two[i].end(); ++it)
{
if (it->_type == "文科")
{
data_three[i][0].push_back(*it); // 添加到data_two[i][0]
}
else if (it->_type == "理科")
{
data_three[i][1].push_back(*it);//添加到data_two[i][1]
}
else if (it->_type == "艺术")
{
data_three[i][2].push_back(*it); //添加到data_two[i][2]
}
}
}
//string str="P(汕头)+Q(艺术,文科,理科)+S(学号,姓名,性别)+T(总分)-Q()-P()-S(学号)%T(总分)";
string str="";
str=m_seek1;//把控件的值付给c++代码
//m_seek="";
if (str.find("%T(")<1000){
BOOL_GRADE = str.substr(str.find("%T") + 3, 4);
str = str.substr(0, str.find("%T"));
}
else
{
//cout << "请输入正确语法" << endl;
// str="请输入正确语法";
// CString cstr(str.c_str()); // 或者CString cstr(str.data());初始化时才行
// cstr = str.c_str(); // 或者cstr=str.data();
// m_value2=cstr; //把c++代码处理后的数据传给控件变量
// m_value="fgf";
// GetDlgItem(IDC_EDIT3)->GetWindowText(cstr);
MessageBox("请输入正确语法");
}
vector<string> strs1 = splitEx(str, "-");
vector<string> strs2 = splitEx(strs1[0], "+");
//删除掉"-"号前的字符串
strs1.erase(strs1.begin());
//+的情况
for (unsigned int i = 0; i < strs2.size(); i++)
{
if (strs2[i].find("P") < 1000)
{
int is_ture = 1;
if (strs2[i].find("广州") < 1000)
{
BOOL_PLACE[0] = 1;
is_ture = 0;
}
if (strs2[i].find("汕头") < 1000)
{
BOOL_PLACE[1] = 1;
is_ture = 0;
}
if (strs2[i].find("珠海") < 1000)
{
BOOL_PLACE[2] = 1;
is_ture = 0;
}
if (strs2[i].find("湛江") < 1000)
{
BOOL_PLACE[3] = 1;
is_ture = 0;
}
if (strs2[i].find("深圳") < 1000)
{
BOOL_PLACE[4] = 1;
is_ture = 0;
}
//如果里面没有任何信息
if (is_ture)
{
BOOL_PLACE[0] = 1;
BOOL_PLACE[1] = 1;
BOOL_PLACE[2] = 1;
BOOL_PLACE[3] = 1;
BOOL_PLACE[4] = 1;
}
}
else if (strs2[i].find("Q") < 1000)
{
int is_ture = 1;
if (strs2[i].find("文科") < 1000)
{
BOOL_TYPE[0] = 1;
is_ture = 0;
}
if (strs2[i].find("理科") < 1000)
{
BOOL_TYPE[1] = 1;
is_ture = 0;
}
if (strs2[i].find("艺术") < 1000)
{
BOOL_TYPE[2] = 1;
is_ture = 0;
}
//如果里面没有任何信息
if (is_ture)
{
BOOL_TYPE[0] = 1;
BOOL_TYPE[1] = 1;
BOOL_TYPE[2] = 1;
}
}
else if (strs2[i].find("S") < 1000)
{
int is_ture = 1;
if (strs2[i].find("学号") < 1000)
{
BOOL_S[0] = 1;
is_ture = 0;
}
if (strs2[i].find("姓名") < 1000)
{
BOOL_S[1] = 1;
is_ture = 0;
}
if (strs2[i].find("性别") < 1000)
{
BOOL_S[2] = 1;
is_ture = 0;
}
if (strs2[i].find("年龄") < 1000)
{
BOOL_S[3] = 1;
is_ture = 0;
}
//如果里面没有任何信息
if (is_ture)
{
BOOL_S[0] = 1;
BOOL_S[1] = 1;
BOOL_S[2] = 1;
BOOL_S[3] = 1;
}
}
else if (strs2[i].find("T") < 1000)
{
int is_ture = 1;
if (strs2[i].find("语文") < 1000)
{
BOOL_T[0] = 1;
is_ture = 0;
}
if (strs2[i].find("数学") < 1000)
{
BOOL_T[1] = 1;
is_ture = 0;
}
if (strs2[i].find("英语") < 1000)
{
BOOL_T[2] = 1;
is_ture = 0;
}
if (strs2[i].find("美术") < 1000 ||
strs2[i].find("历史") < 1000 ||
strs2[i].find("物理") < 1000)
{
BOOL_T[3] = 1;
is_ture = 0;
}
if (strs2[i].find("地理") < 1000)
{
BOOL_T[4] = 1;
is_ture = 0;
}
if (strs2[i].find("总分") < 1000)
{
BOOL_T[5] = 1;
is_ture = 0;
}
//如果里面没有任何信息
if (is_ture)
{
BOOL_T[0] = 1;
BOOL_T[1] = 1;
BOOL_T[2] = 1;
BOOL_T[3] = 1;
BOOL_T[4] = 1;
BOOL_T[5] = 1;
}
}
}
//-的情况
for (unsigned int i = 0; i < strs1.size(); i++)
{
if (strs1[i].find("P") < 1000)
{
if (strs1[i].find("广州") < 1000)
{
BOOL_PLACE[0] = 0;
}
if (strs1[i].find("汕头") < 1000)
{
BOOL_PLACE[1] = 0;
}
if (strs1[i].find("珠海") < 1000)
{
BOOL_PLACE[2] = 0;
}
if (strs1[i].find("湛江") < 1000)
{
BOOL_PLACE[3] = 0;
}
if (strs1[i].find("深圳") < 1000)
{
BOOL_PLACE[4] = 0;
}
//如果里面没有任何信息
if (!(BOOL_PLACE[0] || BOOL_PLACE[1] || BOOL_PLACE[2] || BOOL_PLACE[3] || BOOL_PLACE[4]))
{
BOOL_PLACE[0] = 0;
BOOL_PLACE[1] = 0;
BOOL_PLACE[2] = 0;
BOOL_PLACE[3] = 0;
BOOL_PLACE[4] = 0;
}
}
else if (strs1[i].find("Q") < 1000)
{
if (strs1[i].find("文科") < 1000)
{
BOOL_TYPE[0] = 0;
}
if (strs1[i].find("理科") < 1000)
{
BOOL_TYPE[1] = 0;
}
if (strs1[i].find("艺术") < 1000)
{
BOOL_TYPE[2] = 0;
}
//如果里面没有任何信息
if (!(BOOL_TYPE[0] || BOOL_TYPE[1] || BOOL_TYPE[2]))
{
BOOL_TYPE[0] = 0;
BOOL_TYPE[1] = 0;
BOOL_TYPE[2] = 0;
}
}
else if (strs1[i].find("S") < 1000)
{
int is_ture = 1;
if (strs1[i].find("学号") < 1000)
{
BOOL_S[0] = 0;
is_ture = 0;
}
if (strs1[i].find("姓名") < 1000)
{
BOOL_S[1] = 0;
is_ture = 0;
}
if (strs1[i].find("性别") < 1000)
{
BOOL_S[2] = 0;
is_ture = 0;
}
if (strs1[i].find("年龄") < 1000)
{
BOOL_S[3] = 0;
is_ture = 0;
}
if (is_ture)
{
BOOL_S[0] = 0;
BOOL_S[1] = 0;
BOOL_S[2] = 0;
BOOL_S[3] = 0;
}
}
else if (strs1[i].find("T") < 1000)
{
int is_ture = 1;
if (strs1[i].find("语文") < 1000)
{
BOOL_T[0] = 0;
is_ture = 0;
}
if (strs1[i].find("数学") < 1000)
{
BOOL_T[1] = 0;
is_ture = 0;
}
if (strs1[i].find("英语") < 1000)
{
BOOL_T[2] = 0;
is_ture = 0;
}
if (strs1[i].find("美术") < 1000 ||
strs1[i].find("历史") < 1000 ||
strs1[i].find("物理") < 1000)
{
BOOL_T[3] = 0;
is_ture = 0;
}
if (strs1[i].find("地理") < 1000)
{
BOOL_T[4] = 0;
is_ture = 0;
}
if (strs1[i].find("总分") < 1000)
{
BOOL_T[5] = 0;
is_ture = 0;
}
if (is_ture)
{
BOOL_T[0] = 0;
BOOL_T[1] = 0;
BOOL_T[2] = 0;
BOOL_T[3] = 0;
BOOL_T[4] = 0;
BOOL_T[5] = 0;
}
}
}
//fstream file_four("F://excessive.txt", std::ios::out); //只写打开一个储存排序好的txt文件
ofstream file_four("F://excessive.txt",ios::out);
for (size_t i = 0; i < 5; ++i)
{
//如果开关是开的
if (BOOL_PLACE[i])
{
file_four <<(*data_two[i].begin())._place <<endl <<endl;
}
else
{
continue;
}
for (size_t j = 0; j < 3; ++j)
{
//如果开关是开的
if (BOOL_TYPE[j])
{
file_four << (*data_three[i][j].begin())._type << " : "<< endl;
//按总分降序排序
if (BOOL_GRADE == "总分")
{
sort(data_three[i][j].begin(), data_three[i][j].end(), greatersum);
}
else if (BOOL_GRADE == "英语")
{
sort(data_three[i][j].begin(), data_three[i][j].end(), greaterEnglish);
}
else if (BOOL_GRADE == "数学")
{
sort(data_three[i][j].begin(), data_three[i][j].end(), greatermath);
}
else if (BOOL_GRADE == "语文")
{
sort(data_three[i][j].begin(), data_three[i][j].end(), greaterchinese);
}
else if (BOOL_GRADE == "物理" || BOOL_GRADE == "历史" || BOOL_GRADE == "美术")
{
sort(data_three[i][j].begin(), data_three[i][j].end(), greatercourse1);
}
else if (BOOL_GRADE == "地理")
{
sort(data_three[i][j].begin(), data_three[i][j].end(), greatercourse2);
}
else
{
//cout << "请输入正确语法" << endl;
MessageBox("请输入正确语法");
break;
}
for (auto it = data_three[i][j].begin(); it != data_three[i][j].end(); ++it)
{
//把数据读进student.txt
it->fdisplay(&file_four);
}
}
}
}
//
//P(汕头)+Q(理科)+S+T%T(数学)
fstream file_five("F://excessive.txt", std::ios::in); //以只读打开一个储存排序好的txt文件
string ch="";
string __str;
__str="";
while (!file_five.eof())
{
//file_five.get(ch); // 从文件流中读入下一个字符
getline(file_five,ch,'\n');
__str += ch;
__str+="\r\n";
CString cstr(__str.c_str()); // 或者CString cstr(str.data());初始化时才行
cstr = __str.c_str(); // 或者cstr=str.data();
// cstr+="\r\n";
m_value2=cstr; //把c++代码处理后的数据传给控件变量
}
//cout << __str << endl; // 屏幕输出从文件中读入的字符
file_four.close();
file_five.close();
/*for(auto it=data_three[3][5].begin();it!=data_three[3][5].end();++it)
{
it->_age=0;
it->_chinese=0;
it->_course1=0;
it->_course2=0;
it->_English=0;
it->_place="";
it->_num="";
it->_sex="";
it->_sum=0;
it->_math=0;
}*/
//CFileFind finder;
UpdateData(FALSE);
}
#pragma once
// four 对话框
class four : public CDialogEx
{
DECLARE_DYNAMIC(four)
public:
four(CWnd* pParent = NULL); // 标准构造函数
virtual ~four();
// 对话框数据
enum { IDD = IDD_DIALOG6 };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButton1();
CString m_seek1;
CString m_value2;
};
// project2.cpp : 定义应用程序的类行为。
//
#include "stdafx.h"
#include "project2.h"
#include "project2Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// Cproject2App
BEGIN_MESSAGE_MAP(Cproject2App, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// Cproject2App 构造
Cproject2App::Cproject2App()
{
// 支持重新启动管理器
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
// TODO: 在此处添加构造代码,
// 将所有重要的初始化放置在 InitInstance 中
}
// 唯一的一个 Cproject2App 对象
Cproject2App theApp;
const GUID CDECL BASED_CODE _tlid =
{ 0x30D2B85E, 0x9B1C, 0x4CB3, { 0xBA, 0x40, 0x12, 0x2C, 0x6B, 0xAA, 0xE6, 0xB } };
const WORD _wVerMajor = 1;
const WORD _wVerMinor = 0;
// Cproject2App 初始化
BOOL Cproject2App::InitInstance()
{
// 如果一个运行在 Windows XP 上的应用程序清单指定要
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 将它设置为包括所有要在应用程序中使用的
// 公共控件类。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
// 初始化 OLE 库
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// 创建 shell 管理器,以防对话框包含
// 任何 shell 树视图控件或 shell 列表视图控件。
CShellManager *pShellManager = new CShellManager;
// 标准初始化
// 如果未使用这些功能并希望减小
// 最终可执行文件的大小,则应移除下列
// 不需要的特定初始化例程
// 更改用于存储设置的注册表项
// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
// 分析自动化开关或注册/注销开关的命令行。
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// 应用程序是用 /Embedding 或 /Automation 开关启动的。
//使应用程序作为自动化服务器运行。
if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
{
// 通过 CoRegisterClassObject() 注册类工厂。
COleTemplateServer::RegisterAll();
}
// 应用程序是用 /Unregserver 或 /Unregister 开关启动的。移除
// 注册表中的项。
else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
{
COleObjectFactory::UpdateRegistryAll(FALSE);
AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor);
return FALSE;
}
// 应用程序是以独立方式或用其他开关(如 /Register
// 或 /Regserver)启动的。更新注册表项,包括类型库。
else
{
COleObjectFactory::UpdateRegistryAll();
AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid);
if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppRegister)
return FALSE;
}
Cproject2Dlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: 在此放置处理何时用
// “确定”来关闭对话框的代码
}
else if (nResponse == IDCANCEL)
{
// TODO: 在此放置处理何时用
// “取消”来关闭对话框的代码
}
// 删除上面创建的 shell 管理器。
if (pShellManager != NULL)
{
delete pShellManager;
}
// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
// 而不是启动应用程序的消息泵。
return FALSE;
}
int Cproject2App::ExitInstance()
{
AfxOleTerm(FALSE);
return CWinApp::ExitInstance();
}
// project2.h : PROJECT_NAME 应用程序的主头文件
//
#pragma once
#ifndef __AFXWIN_H__
#error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"
#endif
#include "resource.h" // 主符号
// Cproject2App:
// 有关此类的实现,请参阅 project2.cpp
//
class Cproject2App : public CWinApp
{
public:
Cproject2App();
// 重写
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
// 实现
DECLARE_MESSAGE_MAP()
};
extern Cproject2App theApp;
\ No newline at end of file
// project2.idl : project2.exe 的类型库源
// 此文件将由 MIDL 编译器处理以产生
// 类型库(project2.tlb)。
[ uuid(30D2B85E-9B1C-4CB3-BA40-122C6BAAE60B), version(1.0) ]
library project2
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
// Cproject2Doc 的主调度接口
[ uuid(138BD86D-7208-4D55-92AF-7D388F8DB8CC) ]
dispinterface Iproject2
{
properties:
methods:
};
// Cproject2Doc 的类信息
[ uuid(4E19AEBB-D321-4A0B-B5B7-B9BE7E723ED4) ]
coclass project2
{
[default] dispinterface Iproject2;
};
};
B// Microsoft Visual C++ generated resource script.
REGEDIT
; 此 .REG 文件可能由 SETUP 程序使用。
; 如果 SETUP 程序不可用,则调用
; CWinApp::RegisterShellFileTypes 和 COleObjectFactory::UpdateRegistryAll
; 在 InitInstance 中对下列项自动进行注册。
HKEY_CLASSES_ROOT\project2.Application = project2 Application
HKEY_CLASSES_ROOT\project2.Application\CLSID = {4E19AEBB-D321-4A0B-B5B7-B9BE7E723ED4}
HKEY_CLASSES_ROOT\CLSID\{4E19AEBB-D321-4A0B-B5B7-B9BE7E723ED4} = project2 Application
HKEY_CLASSES_ROOT\CLSID\{4E19AEBB-D321-4A0B-B5B7-B9BE7E723ED4}\ProgId = project2.Application
HKEY_CLASSES_ROOT\CLSID\{4E19AEBB-D321-4A0B-B5B7-B9BE7E723ED4}\LocalServer32 = project2.EXE

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "project2", "project2.vcxproj", "{59CF7FEE-32BA-4E25-9A1A-D3C73B0EBC8C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{59CF7FEE-32BA-4E25-9A1A-D3C73B0EBC8C}.Debug|Win32.ActiveCfg = Debug|Win32
{59CF7FEE-32BA-4E25-9A1A-D3C73B0EBC8C}.Debug|Win32.Build.0 = Debug|Win32
{59CF7FEE-32BA-4E25-9A1A-D3C73B0EBC8C}.Release|Win32.ActiveCfg = Release|Win32
{59CF7FEE-32BA-4E25-9A1A-D3C73B0EBC8C}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{59CF7FEE-32BA-4E25-9A1A-D3C73B0EBC8C}</ProjectGuid>
<RootNamespace>project2</RootNamespace>
<Keyword>MFCProj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<RegisterOutput>true</RegisterOutput>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TypeLibraryName>$(IntDir)project2.tlb</TypeLibraryName>
</Midl>
<ResourceCompile>
<Culture>0x0804</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<RegisterOutput>true</RegisterOutput>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TypeLibraryName>$(IntDir)project2.tlb</TypeLibraryName>
</Midl>
<ResourceCompile>
<Culture>0x0804</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="C:\Users\bo\Desktop\bj_0.bmp" />
<None Include="C:\Users\bo\Desktop\bj_1.bmp" />
<None Include="C:\Users\bo\Desktop\bj_2.bmp" />
<None Include="C:\Users\bo\Desktop\bj_3.bmp" />
<None Include="C:\Users\bo\Desktop\zhifangtu2.bmp" />
<None Include="C:\Users\bo\Desktop\zhifangtu3.bmp" />
<None Include="project2.reg" />
<None Include="ReadMe.txt" />
<None Include="res\project2.ico" />
<None Include="res\project2.rc2" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="DlgProxy.h" />
<ClInclude Include="first.h" />
<ClInclude Include="five.h" />
<ClInclude Include="four.h" />
<ClInclude Include="project2.h" />
<ClInclude Include="project2Dlg.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="second.h" />
<ClInclude Include="second_one.h" />
<ClInclude Include="second_two.h" />
<ClInclude Include="six.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="third.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="DlgProxy.cpp" />
<ClCompile Include="first.cpp" />
<ClCompile Include="five.cpp" />
<ClCompile Include="four.cpp" />
<ClCompile Include="project2.cpp" />
<ClCompile Include="project2Dlg.cpp" />
<ClCompile Include="second.cpp" />
<ClCompile Include="second_one.cpp" />
<ClCompile Include="second_two.cpp" />
<ClCompile Include="six.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="third.cpp" />
</ItemGroup>
<ItemGroup>
<Midl Include="project2.idl" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="project2.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties RESOURCE_FILE="project2.rc" />
</VisualStudio>
</ProjectExtensions>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="ReadMe.txt" />
<None Include="project2.reg" />
<None Include="res\project2.rc2">
<Filter>资源文件</Filter>
</None>
<None Include="res\project2.ico">
<Filter>资源文件</Filter>
</None>
<None Include="C:\Users\bo\Desktop\zhifangtu2.bmp">
<Filter>资源文件</Filter>
</None>
<None Include="C:\Users\bo\Desktop\bj_0.bmp">
<Filter>资源文件</Filter>
</None>
<None Include="C:\Users\bo\Desktop\bj_1.bmp">
<Filter>资源文件</Filter>
</None>
<None Include="C:\Users\bo\Desktop\bj_2.bmp">
<Filter>资源文件</Filter>
</None>
<None Include="C:\Users\bo\Desktop\bj_3.bmp">
<Filter>资源文件</Filter>
</None>
<None Include="C:\Users\bo\Desktop\zhifangtu3.bmp">
<Filter>资源文件</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClInclude Include="project2.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="project2Dlg.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="DlgProxy.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="first.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="second.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="second_one.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="second_two.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="third.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="four.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="five.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="six.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="project2.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="project2Dlg.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="DlgProxy.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="first.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="second.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="second_one.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="second_two.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="third.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="four.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="five.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="six.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Midl Include="project2.idl">
<Filter>源文件</Filter>
</Midl>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="project2.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
\ No newline at end of file
// project2Dlg.cpp : 实现文件
//
#include "stdafx.h"
#include "project2.h"
#include "project2Dlg.h"
#include "DlgProxy.h"
#include "afxdialogex.h"
#include "first.h"
#include "second.h"
#include "third.h"
#include "four.h"
#include "five.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg();
// 对话框数据
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
// Cproject2Dlg 对话框
IMPLEMENT_DYNAMIC(Cproject2Dlg, CDialogEx);
Cproject2Dlg::Cproject2Dlg(CWnd* pParent /*=NULL*/)
: CDialogEx(Cproject2Dlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_pAutoProxy = NULL;
}
Cproject2Dlg::~Cproject2Dlg()
{
// 如果该对话框有自动化代理,则
// 将此代理指向该对话框的后向指针设置为 NULL,以便
// 此代理知道该对话框已被删除。
if (m_pAutoProxy != NULL)
m_pAutoProxy->m_pDialog = NULL;
}
void Cproject2Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(Cproject2Dlg, CDialogEx)
ON_WM_SYSCOMMAND()
ON_WM_CLOSE()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, &Cproject2Dlg::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON2, &Cproject2Dlg::OnBnClickedButton2)
ON_BN_CLICKED(IDC_BUTTON3, &Cproject2Dlg::OnBnClickedButton3)
ON_BN_CLICKED(IDC_BUTTON4, &Cproject2Dlg::OnBnClickedButton4)
ON_BN_CLICKED(IDC_BUTTON5, &Cproject2Dlg::OnBnClickedButton5)
END_MESSAGE_MAP()
// Cproject2Dlg 消息处理程序
BOOL Cproject2Dlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// 将“关于...”菜单项添加到系统菜单中。
// IDM_ABOUTBOX 必须在系统命令范围内。
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
// TODO: 在此添加额外的初始化代码
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
void Cproject2Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialogEx::OnSysCommand(nID, lParam);
}
}
// 如果向对话框添加最小化按钮,则需要下面的代码
// 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
// 这将由框架自动完成。
void Cproject2Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // 用于绘制的设备上下文
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 使图标在工作区矩形中居中
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// 绘制图标
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialogEx::OnPaint();
}
}
//当用户拖动最小化窗口时系统调用此函数取得光标
//显示。
HCURSOR Cproject2Dlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
// 当用户关闭 UI 时,如果控制器仍保持着它的某个
// 对象,则自动化服务器不应退出。这些
// 消息处理程序确保如下情形: 如果代理仍在使用,
// 则将隐藏 UI;但是在关闭对话框时,
// 对话框仍然会保留在那里。
void Cproject2Dlg::OnClose()
{
if (CanExit())
CDialogEx::OnClose();
}
void Cproject2Dlg::OnOK()
{
//if (CanExit())
// CDialogEx::OnOK();
}
void Cproject2Dlg::OnCancel()
{
if (CanExit())
CDialogEx::OnCancel();
}
BOOL Cproject2Dlg::CanExit()
{
// 如果代理对象仍保留在那里,则自动化
// 控制器仍会保持此应用程序。
// 使对话框保留在那里,但将其 UI 隐藏起来。
if (m_pAutoProxy != NULL)
{
ShowWindow(SW_HIDE);
return FALSE;
}
return TRUE;
}
void Cproject2Dlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
first p;
p.DoModal();
}
void Cproject2Dlg::OnBnClickedButton2()
{
// TODO: 在此添加控件通知处理程序代码
second p;
p.DoModal();
}
void Cproject2Dlg::OnBnClickedButton3()
{
// TODO: 在此添加控件通知处理程序代码
third p;
p.DoModal();
}
void Cproject2Dlg::OnBnClickedButton4()
{
// TODO: 在此添加控件通知处理程序代码
four p;
p.DoModal();
}
void Cproject2Dlg::OnBnClickedButton5()
{
// TODO: 在此添加控件通知处理程序代码
five p;
p.DoModal();
}
// project2Dlg.h : 头文件
//
#pragma once
class Cproject2DlgAutoProxy;
// Cproject2Dlg 对话框
class Cproject2Dlg : public CDialogEx
{
DECLARE_DYNAMIC(Cproject2Dlg);
friend class Cproject2DlgAutoProxy;
// 构造
public:
Cproject2Dlg(CWnd* pParent = NULL); // 标准构造函数
virtual ~Cproject2Dlg();
// 对话框数据
enum { IDD = IDD_PROJECT2_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
Cproject2DlgAutoProxy* m_pAutoProxy;
HICON m_hIcon;
BOOL CanExit();
// 生成的消息映射函数
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnClose();
virtual void OnOK();
virtual void OnCancel();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButton1();
afx_msg void OnBnClickedButton2();
afx_msg void OnBnClickedButton3();
afx_msg void OnBnClickedButton4();
afx_msg void OnBnClickedButton5();
};
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 7.00.0555 */
/* at Sat Jul 05 11:04:21 2014
*/
/* Compiler settings for project2.idl:
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555
protocol : dce , ms_ext, c_ext, robust
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
DECLSPEC_UUID(), MIDL_INTERFACE()
*/
/* @@MIDL_FILE_HEADING( ) */
#pragma warning( disable: 4049 ) /* more than 64k source lines */
/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 475
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif // __RPCNDR_H_VERSION__
#ifndef __project2_h_h__
#define __project2_h_h__
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
/* Forward Declarations */
#ifndef __Iproject2_FWD_DEFINED__
#define __Iproject2_FWD_DEFINED__
typedef interface Iproject2 Iproject2;
#endif /* __Iproject2_FWD_DEFINED__ */
#ifndef __project2_FWD_DEFINED__
#define __project2_FWD_DEFINED__
#ifdef __cplusplus
typedef class project2 project2;
#else
typedef struct project2 project2;
#endif /* __cplusplus */
#endif /* __project2_FWD_DEFINED__ */
#ifdef __cplusplus
extern "C"{
#endif
#ifndef __project2_LIBRARY_DEFINED__
#define __project2_LIBRARY_DEFINED__
/* library project2 */
/* [version][uuid] */
EXTERN_C const IID LIBID_project2;
#ifndef __Iproject2_DISPINTERFACE_DEFINED__
#define __Iproject2_DISPINTERFACE_DEFINED__
/* dispinterface Iproject2 */
/* [uuid] */
EXTERN_C const IID DIID_Iproject2;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("138BD86D-7208-4D55-92AF-7D388F8DB8CC")
Iproject2 : public IDispatch
{
};
#else /* C style interface */
typedef struct Iproject2Vtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
Iproject2 * This,
/* [in] */ REFIID riid,
/* [annotation][iid_is][out] */
__RPC__deref_out void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
Iproject2 * This);
ULONG ( STDMETHODCALLTYPE *Release )(
Iproject2 * This);
HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )(
Iproject2 * This,
/* [out] */ UINT *pctinfo);
HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )(
Iproject2 * This,
/* [in] */ UINT iTInfo,
/* [in] */ LCID lcid,
/* [out] */ ITypeInfo **ppTInfo);
HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )(
Iproject2 * This,
/* [in] */ REFIID riid,
/* [size_is][in] */ LPOLESTR *rgszNames,
/* [range][in] */ UINT cNames,
/* [in] */ LCID lcid,
/* [size_is][out] */ DISPID *rgDispId);
/* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )(
Iproject2 * This,
/* [in] */ DISPID dispIdMember,
/* [in] */ REFIID riid,
/* [in] */ LCID lcid,
/* [in] */ WORD wFlags,
/* [out][in] */ DISPPARAMS *pDispParams,
/* [out] */ VARIANT *pVarResult,
/* [out] */ EXCEPINFO *pExcepInfo,
/* [out] */ UINT *puArgErr);
END_INTERFACE
} Iproject2Vtbl;
interface Iproject2
{
CONST_VTBL struct Iproject2Vtbl *lpVtbl;
};
#ifdef COBJMACROS
#define Iproject2_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define Iproject2_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define Iproject2_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define Iproject2_GetTypeInfoCount(This,pctinfo) \
( (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) )
#define Iproject2_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
( (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) )
#define Iproject2_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
( (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) )
#define Iproject2_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
( (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* __Iproject2_DISPINTERFACE_DEFINED__ */
EXTERN_C const CLSID CLSID_project2;
#ifdef __cplusplus
class DECLSPEC_UUID("4E19AEBB-D321-4A0B-B5B7-B9BE7E723ED4")
project2;
#endif
#endif /* __project2_LIBRARY_DEFINED__ */
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
#ifdef __cplusplus
}
#endif
#endif
/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */
/* link this file in with the server and any clients */
/* File created by MIDL compiler version 7.00.0555 */
/* at Sat Jul 05 11:04:21 2014
*/
/* Compiler settings for project2.idl:
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555
protocol : dce , ms_ext, c_ext, robust
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
DECLSPEC_UUID(), MIDL_INTERFACE()
*/
/* @@MIDL_FILE_HEADING( ) */
#pragma warning( disable: 4049 ) /* more than 64k source lines */
#ifdef __cplusplus
extern "C"{
#endif
#include <rpc.h>
#include <rpcndr.h>
#ifdef _MIDL_USE_GUIDDEF_
#ifndef INITGUID
#define INITGUID
#include <guiddef.h>
#undef INITGUID
#else
#include <guiddef.h>
#endif
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
#else // !_MIDL_USE_GUIDDEF_
#ifndef __IID_DEFINED__
#define __IID_DEFINED__
typedef struct _IID
{
unsigned long x;
unsigned short s1;
unsigned short s2;
unsigned char c[8];
} IID;
#endif // __IID_DEFINED__
#ifndef CLSID_DEFINED
#define CLSID_DEFINED
typedef IID CLSID;
#endif // CLSID_DEFINED
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
#endif !_MIDL_USE_GUIDDEF_
MIDL_DEFINE_GUID(IID, LIBID_project2,0x30D2B85E,0x9B1C,0x4CB3,0xBA,0x40,0x12,0x2C,0x6B,0xAA,0xE6,0x0B);
MIDL_DEFINE_GUID(IID, DIID_Iproject2,0x138BD86D,0x7208,0x4D55,0x92,0xAF,0x7D,0x38,0x8F,0x8D,0xB8,0xCC);
MIDL_DEFINE_GUID(CLSID, CLSID_project2,0x4E19AEBB,0xD321,0x4A0B,0xB5,0xB7,0xB9,0xBE,0x7E,0x72,0x3E,0xD4);
#undef MIDL_DEFINE_GUID
#ifdef __cplusplus
}
#endif
B//{{NO_DEPENDENCIES}}
// second.cpp : 实现文件
//
#include "stdafx.h"
#include "project2.h"
#include "second.h"
#include "afxdialogex.h"
#include "second_one.h"
#include "second_two.h"
// second 对话框
IMPLEMENT_DYNAMIC(second, CDialogEx)
second::second(CWnd* pParent /*=NULL*/)
: CDialogEx(second::IDD, pParent)
{
}
second::~second()
{
}
void second::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(second, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON1, &second::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON2, &second::OnBnClickedButton2)
END_MESSAGE_MAP()
// second 消息处理程序
void second::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
second_one p;
p.DoModal();
}
void second::OnBnClickedButton2()
{
// TODO: 在此添加控件通知处理程序代码
second_two p;
p.DoModal();
}
#pragma once
// second 对话框
class second : public CDialogEx
{
DECLARE_DYNAMIC(second)
public:
second(CWnd* pParent = NULL); // 标准构造函数
virtual ~second();
// 对话框数据
enum { IDD = IDD_DIALOG2 };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButton1();
afx_msg void OnBnClickedButton2();
};
// second_one.cpp : 实现文件
//
#include "stdafx.h"
#include "project2.h"
#include "second_one.h"
#include "afxdialogex.h"
#include <iostream>
#include <stdio.h>
#include<fstream>
#include <malloc.h>
#include <conio.h>
#include <stdlib.h>
//#include <cstdlib>
#include <string>
#include <math.h>
using namespace std;
#define CLRSCR system("cls")
#define PRINT_TITLE "\n序号\t考号\t\t姓名\t语文\t数学\t英语\t总分\n"
#define PRINT_FORMAT "%d\t%s\t%s\t%d\t%d\t%d\t%d\n",i,p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score
#define WRITE_FORMAT "%s\t%s\t%d\t%d\t%d\t%d\n",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score
#define READ_FORMAT "%s %s %d %d %d %d",&p->stu.num,&p->stu.name,&p->stu.Chinese,&p->stu.math,&p->stu.English,&p->stu.count_score
// second_one 对话框
IMPLEMENT_DYNAMIC(second_one, CDialogEx)
second_one::second_one(CWnd* pParent /*=NULL*/)
: CDialogEx(second_one::IDD, pParent)
, m_stu(_T(""))
{
}
second_one::~second_one()
{
}
void second_one::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_stu);
}
BEGIN_MESSAGE_MAP(second_one, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON1, &second_one::OnBnClickedButton1)
END_MESSAGE_MAP()
// second_one 消息处理程序
class student_bx2
{
public:
char num[40];
char name[20];//三个汉字长度为6个字节,应多定义一个字节来存放字符串结束符'\0'
int Chinese;
int math;
int English;
int count_score;
};
//定义单链表类
class node2
{
public:
student_bx2 stu;
node2 *next;
};
int MySelect(node2 * head,node2 *temp)
{
int i=0;
node2 *p,*tp=temp;
p=head->next;
FILE *fp;
char file[15]={"f:\\English.txt"};
if((fp=fopen(file,"w+"))==NULL)
{
// printf("\n\t文件创建失败\n");
exit(0);
}
while (NULL!=p)
{
if(p->stu.English>100&&p->stu.count_score>300)
{
node2 *end;
end = (node2 *)malloc(sizeof(node2));
tp->next=end;
tp=end;
tp->next=NULL;
tp->stu=p->stu;
if(i==0)
// printf(PRINT_TITLE);
i++;
// printf(PRINT_FORMAT);
if(p->next==NULL)//不要最后一行的回车,这样的话导入该文件时就不会有末尾的乱码
fprintf(fp,"%s\t%s\t%d\t%d\t%d\t%d",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score);
else
fprintf(fp,WRITE_FORMAT);
}
p=p->next;
}
// fclose(fp);
if(i==0)
//printf("\n\t英语超过100分且总分成绩超过300分的学生人数为零\n");
return i;
}
void Fprintf(node2 *head)
{
char file[40]={"f:\\boxiang_stu2.txt"};
FILE *fp;
if((fp=fopen(file,"w+"))==NULL)
{
//printf("\n\t文件打开失败,按任意键退出\n");
getch();
exit(0);
}
node2 *p=head->next;
while(NULL!=p)
{
if(p->next==NULL)//不要最后一行的回车,这样的话导入该文件时就不会有末尾的乱码
fprintf(fp,"%s\t%s\t%d\t%d\t%d\t%d",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score);
else
fprintf(fp,WRITE_FORMAT);
p=p->next;
}
fclose(fp);
}
void InsertSort(node2 *head)//总分从大到小排序
{
node2 *p,*q,*u,*h,*w,*n;
int j=0;
p=head->next;
while(p!=NULL)
{
j++;
p=p->next;
}
for(int i=0;i<j-1;i++)
{
p=head;
q=p->next;
for(int z=0;z<=j-2-i;z++)
{
int y=0;
if((q->next->stu.count_score)>(p->next->stu.count_score))
{
n=q->next;
u=n->next;
w=p->next;
p->next=n;
n->next=w;
q->next=u;
p=p->next;
y=1;
}
if(y==0)
{
p=p->next;
q=q->next;
}
}
}
}
void FscanfFromFile(node2 *head)//cdsgfdgfhhhhhhhhhhhhhhhhhhhhhhh
{
char file[25]="f:\\boxiang_stu.txt";
FILE *fp;
if((fp=fopen(file,"r"))==NULL)
{
//printf("\n\t文件打开失败,按任意键退出\n");
getch();
exit(0);
}
node2 *p=head;
while(!feof(fp))
{
node2 *end;
end = (node2 *)malloc(sizeof(node2));
p->next=end;
p=end;
p->next=NULL;
fscanf(fp,READ_FORMAT);
}
//printf("\n\t信息导入成功\n");
InsertSort(head);
Fprintf(head);
fclose(fp);
}
void ShowList(node2 *head)//带头结点的链表
{
node2 *p=head->next;
int i=0;
//printf ("\t\t\t成绩汇总排序表\n");
// printf (PRINT_TITLE);
while(NULL!=p )
{ i++;
printf (PRINT_FORMAT);
p=p->next;
}
}
void FprintfToFile(node2 *head)
{
char file[50]={"f:\\boxiang_stu2.txt"};
//printf("\n输入要写入的文件名:");
//scanf("%s",file);
FILE *fp;
if((fp=fopen(file,"w+"))==NULL)
{
printf("\n\t文件创建失败\n");
exit(0);
}
node2 *p=head->next;
while(NULL!=p)
{
if(p->next==NULL)//不要最后一行的回车,这样的话导入该文件时就不会有末尾的乱码
fprintf(fp,"%s\t%s\t%d\t%d\t%d\t%d",p->stu.num,p->stu.name,p->stu.Chinese,p->stu.math,p->stu.English,p->stu.count_score);
else
fprintf(fp,WRITE_FORMAT);
p=p->next;
}
fclose(fp);
printf("\n\t数据写入成功\n",file);//printf输出双引号要用转义字\"
}
node2 *ClearList(node2 *head)
{
node2 *p=head->next;
while(NULL!=p)
{
node2 *tp=p->next;
free(p);
p=tp;
}
return head->next=NULL;
}
void second_one::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
ofstream out;
string num,name;
int chinese,math,english,sum;
out.open("f:\\stu.txt",ios::out);
out<<m_stu;
out.close();
ifstream in2("f:\\stu.txt",ios::in);
ofstream out2("f:\\boxiang_stu.txt",ios::app);
while(!in2.eof())
{
in2>>num>>name>>chinese>>math>>english;
sum=chinese+math+english;
out2<<endl<<num<<"\t"<<name<<"\t"<<chinese<<"\t"<<math<<"\t"<<english<<"\t"<<sum;
}
in2.close();
out2.close();
////////////////////
node2 *head;
int i=0;
head = (node2 *)malloc(sizeof(node2));
strcpy(head->stu.num," ");
strcpy(head->stu.name," ");
head->stu.Chinese=0;
head->stu.math=0;
head->stu.English=0;
head->stu.count_score=0;
node2 *temp= (node2 *)malloc(sizeof(node2));//保存查找结果的头结点
FscanfFromFile(head);
ShowList(head);
//重新写入数据
ifstream in3;
ofstream out3;
in3.open("f:\\boxiang_stu2.txt",ios::in);
out3.open("f:\\boxiang_stu.txt",ios::out);
while(!in3.eof())
{
in3>>num>>name>>chinese>>math>>english>>sum;
out3<<endl<<num<<"\t"<<name<<"\t"<<chinese<<"\t"<<math<<"\t"<<english<<"\t"<<sum;
}
//显示处理后的数据
ifstream in4;
in4.open("f:\\boxiang_stu.txt",ios::out);
string str,str2;
while(!in4.eof())
{
getline(in4,str,'\n');
str2+=str+"\r\n";
CString cstr(str2.c_str());
cstr=str2.c_str();
m_stu=cstr; //
}
UpdateData(FALSE);
}
#pragma once
// second_one 对话框
class second_one : public CDialogEx
{
DECLARE_DYNAMIC(second_one)
public:
second_one(CWnd* pParent = NULL); // 标准构造函数
virtual ~second_one();
// 对话框数据
enum { IDD = IDD_DIALOG3 };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButton1();
CString m_stu;
};
// second_two.cpp : 实现文件
//
#include "stdafx.h"
#include "project2.h"
#include "second_two.h"
#include "afxdialogex.h"
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
// second_two 对话框
IMPLEMENT_DYNAMIC(second_two, CDialogEx)
second_two::second_two(CWnd* pParent /*=NULL*/)
: CDialogEx(second_two::IDD, pParent)
, m_seek(_T(""))
, m_seek2(_T(""))
{
}
second_two::~second_two()
{
}
void second_two::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_seek);
DDX_Text(pDX, IDC_EDIT2, m_seek2);
}
BEGIN_MESSAGE_MAP(second_two, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON1, &second_two::OnBnClickedButton1)
END_MESSAGE_MAP()
// second_two 消息处理程序
void second_two::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
string num;
string name;
string chinese;
string math;
string english;
string sum;
string num1;
ifstream in;
string str,str2;
num1=m_seek;
in.open("f:\\boxiang_stu.txt",ios::in);
while(!in.eof())
{
// getline(in,str,'\n');
/// str2+=str+"\r\n";
in>>num>>name>>chinese>>math>>english>>sum;
if(num==num1)
{
str2+=num+" "+name+" "+chinese+" "+math+" "+english+" "+sum+"\r\n";
CString cstr(str2.c_str());
cstr=str2.c_str();
m_seek2=cstr;
}
}
UpdateData(FALSE);
}
#pragma once
// second_two 对话框
class second_two : public CDialogEx
{
DECLARE_DYNAMIC(second_two)
public:
second_two(CWnd* pParent = NULL); // 标准构造函数
virtual ~second_two();
// 对话框数据
enum { IDD = IDD_DIALOG4 };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButton1();
CString m_seek;
CString m_seek2;
};
// six.cpp : 实现文件
//
#include "stdafx.h"
#include "project2.h"
#include "six.h"
#include "afxdialogex.h"
#include<iostream>
#include<string>
#include<fstream> //文件操作头文件
#include<vector> //容器头文件
#include <algorithm> //容器排序所用头文件
#include <functional>//容器排序所用头文件
using namespace std;
/*
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::fstream;
using std::vector;
using std::sort;
using std::greater; //容器排序的时候会用到
using std::less; //容器排序的时候会用到*/
//string BOOL_GRADE;
int BOOL__[5][3]={0, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0}; //开关
// six 对话框
IMPLEMENT_DYNAMIC(six, CDialogEx)
six::six(CWnd* pParent /*=NULL*/)
: CDialogEx(six::IDD, pParent)
, m_seek_six(_T(""))
, m_value_six(_T(""))
{
}
six::~six()
{
}
void six::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_seek_six);
DDX_Text(pDX, IDC_EDIT2, m_value_six);
}
BEGIN_MESSAGE_MAP(six, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON1, &six::OnBnClickedButton1)
END_MESSAGE_MAP()
// six 消息处理程序
/*void System()
{
cout << "输入查询语句格式如下:" << endl
<< "(地区1,类型)+(地区1,类型)" << endl;
}
class Student_yong3 //学生类
{
public:
Student_yong3();
~Student_yong3();
int finput(fstream *fp); //文件输入数据
void fdisplay(fstream *fp); //文件输入数据
void input(); //控制台输入数据
void display(); //控制台输出数据
void setMath(); //设定数学成绩
void setChinese(); //设定语文成绩
void setEnglish(); //设定英语成绩
void getMath(); //获取数学成绩
void getChinese(); //获取语文成绩
void getEnglish(); //获取英语成绩
string _num; //考号
string _name; //姓名
string _sex; //性别
unsigned int _age; //年龄
string _place; //地点
string _type; //考生类型
string _wchar[5]; //储存前缀
unsigned int _chinese; //语文
unsigned int _math; //数学
unsigned int _English; //英语
unsigned int _course1; //课程一
unsigned int _course2; //课程二
unsigned int _sum; //总成绩
unsigned int _list_num; //序号
fstream *_fp; //文件指针
};*/
/*----------------------排序规则------------------------------*/
//总分降序排序
/*
bool greatersum(const Student_yong3& s1, const Student_yong3& s2)
{
return s1._sum > s2._sum;
}
//英语成绩降序排序
bool greaterEnglish(const Student_yong3& s1, const Student_yong3& s2)
{
return s1._English > s2._English;
}
//语文成绩降序排序
bool greaterchinese(const Student_yong3& s1, const Student_yong3& s2)
{
return s1._chinese > s2._chinese;
}
//数学成绩降序排序
bool greatermath(const Student_yong3& s1, const Student_yong3& s2)
{
return s1._math > s2._math;
}
//第一科降序排序
bool greatercourse1(const Student_yong3& s1, const Student_yong3& s2)
{
return s1._course1 > s2._course1;
}
//第二科降序排序
bool greatercourse2(const Student_yong3& s1, const Student_yong3& s2)
{
return s1._course2 > s2._course2;
}*/
/*-------------------------排序规则--------------------------*/
/*
Student_yong3::Student_yong3()
{
_fp = 0; //初始化文件指针
}
Student_yong3 ::~Student_yong3()
{
}
int Student_yong3::finput(fstream *fp) //具体化finput()
{
_fp = fp;
(*_fp) >> _num >> _name //设定学号姓名
>> _sex >> _age //设定性别和年龄
>> _place >> _type //地点和考生类型
>> _wchar[0] >> _chinese >> _wchar[1] >> _math >> _wchar[2] >> _English; //设定3科成绩
if (_type == "文科")
{
(*_fp) >> _wchar[3] >> _course1 >> _wchar[4] >> _course2; //设定历史和地理
}
else
{
(*_fp) >> _wchar[3] >> _course1; //设定物理或美术
}
if (_num == "" || _name == "") //如果没有读到数据返回false
{
return 0;
}
else
{
//计算总成绩
_sum = _math + _English + _chinese + _course1 + _course2;
return 1;
}
}
void Student_yong3::fdisplay(fstream *fp) //具体化fdisplay
{
(*fp) << _num << " " << _name << " " //文件输出学号姓名
<< _sex << " " << _age << " " //文件输出性别和年龄
<< _wchar[0] << _chinese << _wchar[1] << _math << _wchar[2] << _English; //文件输出3科成绩
if (_type == "文科")
{
(*fp) << _wchar[3] << _course1 << _wchar[4] << _course2; //文件输出历史和地理
}
else
{
(*fp) << _wchar[3] << _course1; //文件输出物理或美术
}
(*fp) << "总分 " << _sum << endl; //文件输出总分
}
/* 字符串处理 ,根据符号分类添加到容器 */
/*
vector<string> splitEx(const string& src, string separate_character)
{
vector<string> strs;
int separate_characterLen = separate_character.size();//分割字符串的长度,这样就可以支持如“,,”多字符串的分隔符
int lastPosition = 0, index = -1;
while (-1 != (index = src.find(separate_character, lastPosition)))
{
strs.push_back(src.substr(lastPosition, index - lastPosition));
lastPosition = index + separate_characterLen;
}
string lastString = src.substr(lastPosition);//截取最后一个分隔符后的内容
if (!lastString.empty())
strs.push_back(lastString);//如果最后一个分隔符后还有内容就入队
return strs;
}
*/
void six::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
/* UpdateData(TRUE);
fstream file_one("F://data_student6.txt"); //打开第一个文件
if (!file_one) //如果打开失败
{
cout << "open error!" << endl;//显示出错信息
abort();//程序退出
}
vector<Student_yong3>stu_data; //定义一个空的stu_date容器,储存文件的全部信息
do
{
Student_yong3 stu;
if (stu.finput(&file_one)) //调用finpu(),输入成绩
{
stu_data.push_back(stu); //添加对象到容器末端
}
else
{
file_one.close(); //关闭文件
break; //跳出循环
}
} while (true);
vector<Student_yong3>data_two[5]; //定义一个容器数组
//遍历stu_data
for (auto it = stu_data.begin(); it != stu_data.end(); ++it)
{
if ((*it)._place == "广州")
{
data_two[0].push_back(*it); //添加到data_two[0]
}
else if ((*it)._place == "汕头")
{
data_two[1].push_back(*it); //添加到data_two[1]
}
else if ((*it)._place == "珠海")
{
data_two[2].push_back(*it); //添加到data_two[2]
}
else if ((*it)._place == "湛江")
{
data_two[3].push_back(*it); //添加到data_two[3]
}
else if ((*it)._place == "深圳")
{
data_two[4].push_back(*it); //添加到data_two[4]
}
}
vector<Student_yong3>data_three1[5][3];
for (size_t i = 0; i < 5; ++i)
{
for (auto it = data_two[i].begin(); it != data_two[i].end(); ++it)
{
if (it->_type == "文科")
{
data_three1[i][0].push_back(*it); // 添加到data_two[i][0]
}
else if (it->_type == "理科")
{
data_three1[i][1].push_back(*it);//添加到data_two[i][1]
}
else if (it->_type == "艺术")
{
data_three1[i][2].push_back(*it); //添加到data_two[i][2]
}
}
}
System();
//string str="P(汕头)+Q(艺术,文科,理科)+S(学号,姓名,性别)+T(总分)-Q()-P()-S(学号)%T(总分)";
string str_1="";
//cin >> str;
str_1=m_seek_six;
vector<string> strs2 = splitEx(str_1, "+");
//+的情况
for (unsigned int i = 0; i < strs2.size(); i++)
{
if (strs2[i].find("(广州") < 1000)
{
string str1__= strs2[i].substr(strs2[i].find("广州")+5, 4);
if (str1__ == "文科")
BOOL__[0][0] = 1;
if (str1__ == "理科")
BOOL__[0][1] = 1;
if (str1__== "艺术")
BOOL__[0][2] = 1;
}
if (strs2[i].find("(汕头") < 1000)
{
string str2__ = strs2[i].substr(strs2[i].find("汕头") + 5, 4);
if (str2__ == "文科")
BOOL__[1][0] = 1;
if (str2__ == "理科")
BOOL__[1][1] = 1;
if (str2__ == "艺术")
BOOL__[1][2] = 1;
}
if (strs2[i].find("(珠海") < 1000)
{
string str3__ = strs2[i].substr(strs2[i].find("珠海") + 5, 4);
if (str3__ == "文科")
BOOL__[2][0] = 1;
if (str3__ == "理科")
BOOL__[2][1] = 1;
if (str3__ == "艺术")
BOOL__[2][2] = 1;;
}
if (strs2[i].find("(湛江") < 1000)
{
string str3__ = strs2[i].substr(strs2[i].find("湛江") + 5, 4);
if (str3__ == "文科")
BOOL__[3][0] = 1;
if (str3__ == "理科")
BOOL__[3][1] = 1;
if (str3__ == "艺术")
BOOL__[3][2] = 1;;
}
if (strs2[i].find("(深圳") < 1000)
{
{
string str3__ = strs2[i].substr(strs2[i].find("深圳") + 5, 4);
if (str3__ == "文科")
BOOL__[4][0] = 1;
if (str3__ == "理科")
BOOL__[4][1] = 1;
if (str3__ == "艺术")
BOOL__[4][2] = 1;;
}
}
}
fstream file_six("F://scholar.txt",std::ios::out); //打开第一个文件
for (size_t i = 0; i < 5; ++i)
{
for (size_t j = 0; j < 3; ++j)
{
//如果开关是开的
if (BOOL__[i][j])
{
file_six << (*data_three1[i][j].begin())._place
<< (*data_three1[i][j].begin())._type << " 状元: " << endl;
//按总分降序排序
sort(data_three1[i][j].begin(), data_three1[i][j].end(), greatersum);
auto it = data_three1[i][j].begin();
//把数据读进student.txt
it->fdisplay(&file_six);
//(汕头,文科)+(广州,理科)
}
}
}
string _str_one_1;
string _str_two_1;
fstream file_six_2("F://scholar.txt");
while (!file_six_2.eof())
{
getline(file_six_2, _str_one_1, '\n'); // 从文件流中读入下一个字符
_str_two_1 += _str_one_1 + "\r\n";
CString cstr(_str_two_1.c_str());
cstr=_str_two_1.c_str();
m_value_six=cstr;
}
//关闭文件
//cout << _str_two_1 << endl;
file_six_2.close();
UpdateData(FALSE); */
}
此差异已折叠。
// stdafx.cpp : 只包括标准包含文件的源文件
// project2.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
此差异已折叠。
#pragma once
// 包括 SDKDDKVer.h 将定义最高版本的可用 Windows 平台。
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将
// WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
#include <SDKDDKVer.h>
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册