| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 436 人关注过本帖
标题:[讨论][求助]源程序代码分析
只看楼主 加入收藏
yuemoon
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-6-29
收藏
 问题点数:0 回复次数:0 
[讨论][求助]源程序代码分析

该程序是关于一个招聘系统。
//menu.cpp(模块1)
#include<iostream.h>
#include<stdlib.h>

extern void readin(void);
extern int Treatinf(void);
extern void export(void);

void main()
{
int mmm=1,nnn=1,kkk=0;
while(mmm)
{system("cls");
while(nnn)
{
system("cls"); //清屏
cout<<"\n\n\n\t\t\t 干部招聘管理系统 "<<endl;
cout<<"\t\t\t-----------------------------"<<endl;
cout<<"\t\t\t 1. 读入数据"<<endl;
cout<<"\t\t\t 2. 数据处理"<<endl;
cout<<"\t\t\t 3. 结果输出"<<endl;
cout<<"\t\t\t 0. 退出系统"<<endl;
cout<<"\t\t\t------------------------------"<<endl;
cout<<"\n\t\t\t请选择: ";
cin>>kkk;
if(kkk>=0&&kkk<=3)nnn=0;
}
switch(kkk)
{
case 1:
system("cls");
readin();
break;
case 2:
system("cls");
Treatinf();
break;
case 3:
system("cls");
export();
break;
case 0:cout<<"\n\n\n 退出系统,运行结束!\n\n"<<endl;
mmm=0;
break;
}
nnn=1;
}
system("exit"); //返回Windows

}
//Treatinf.cpp 信息处理模块(模块2)

#include<iostream.h>
#include<fstream.h>
#include<stdlib.h>
#include<string.h>
#include"invcad.h"

void Calcut(Tinform &inf, int count);
void Arrange(int count);

Tinform Tlist1[20];

int main(void)
{
cout<<"进行信息处理"<<endl;

Tinform inform;
int count=0;

ifstream infile("filelist.txt",ios::in);

if(!infile)
{
cout<<"无法打开原始信息文件filelist.txt!";
return 1;
}


while(infile>>inform.name)
{
infile>>inform.sex;
infile>>inform.age;
infile>>inform.schoolrecord;
infile>>inform.worklen;

infile>>inform.pol;
infile>>inform.chn;
infile>>inform.eng;
infile>>inform.com;
infile>>inform.oral;

count+=1;

Calcut(inform, count-1);//调用计算填表模块

}

Arrange(count); //调用排序模块

infile.close();

ofstream outfile("cjfilelist.txt",ios::out);

for(int i=0; i<count; i++)
{ outfile<<Tlist1[i].name<<" ";
outfile<<Tlist1[i].sex<<" ";
outfile<<Tlist1[i].age<<" ";
outfile<<Tlist1[i].schoolrecord<<" ";
outfile<<Tlist1[i].worklen<<" ";

outfile<<Tlist1[i].pol<<" ";
outfile<<Tlist1[i].chn<<" ";
outfile<<Tlist1[i].eng<<" ";
outfile<<Tlist1[i].com<<" ";
outfile<<Tlist1[i].oral<<" ";

outfile<<Tlist1[i].Sage<<" ";
outfile<<Tlist1[i].Srecord<<" ";
outfile<<Tlist1[i].Swlen<<" ";

outfile<<Tlist1[i].total<<"\n";
}

return 1;
}

void Calcut(Tinform &inf, int count)
{
cout<<"调用计算填表模块"<<endl;

int xueli[4]={0,50,75,100};
float age[26]={70,72,74,76,78,80,84,88,92,96,100,97.5,95,92.5,90,87.5,85,82.5,80,77.5,75,74,73,72,71,70};
int worktime[7]={0,70,100,80,60,40,20};


//计算学历分

if ( !strcmp(inf.schoolrecord,"博士") ) {inf.Srecord = (float)xueli[3];}
if ( !strcmp(inf.schoolrecord,"硕士") ) {inf.Srecord = (float)xueli[2];}
if ( !strcmp(inf.schoolrecord,"本科") ) {inf.Srecord = (float)xueli[1];}
if ( !strcmp(inf.schoolrecord,"其他") ) {inf.Srecord = (float)xueli[0];}

//计算年龄分
inf.Sage = age[inf.age-30];

//计算工作经历分
if( inf.worklen>=0 && inf.worklen<=6)
inf.Swlen = (float)worktime[inf.worklen];
else inf.Swlen = 0;

//计算总分
inf.total=inf.Srecord+inf.Sage+inf.Swlen
+inf.pol+inf.chn+inf.eng+inf.com+inf.oral*2;

//将成绩填入成绩总表中
Tlist1[count]=inf;

}

void Arrange(int count)
{
cout<<"调用排序模块"<<endl;

Tinform temp;
int i,j;
for(i=0; i<count; i++)
for(j=i+1;j<count;j++)
{
if(Tlist1[i].total<Tlist1[j].total)
{
temp=Tlist1[i];
Tlist1[i]=Tlist1[j];
Tlist1[j]=temp;
}
}

}
//Readin.cpp(读入模块)
# include<iostream.h>
# include<fstream.h>
# include<stdlib.h>
# include"invcad.h"
#include<string.h>

void readin(void)
{
ofstream outfile("filelist.txt",ios::app);
char yes1,yes2;
Tinform inform;
int mmm=1,mm=1;
Tdate date;

while(mmm)
{
system("cls");

cout<<"\n\n\n请输入应聘者个人信息: 姓名(中文): ";
cin>>inform.name;
while(mm){
cout<<" 性别 (男/女): ";
cin>>inform.sex;
if(strcmp(inform.sex,"男")!=0&&strcmp(inform.sex,"女")!=0)
{cout<<"请重新输入:";}
else{mm=0;}
};
mm=1;
cout<<" 年龄: ";
cin>>inform.age;
cout<<" 学历(博士/硕士/本科/其他): ";
cin>>inform.schoolrecord;
cout<<" 工龄: ";
cin>>inform.worklen;

cout<<"\n 各门成绩: 政治: ";
cin>>inform.pol;
cout<<" 语文: ";
cin>>inform.chn;
cout<<" 英语: ";
cin>>inform.eng;
cout<<" 计算机: ";
cin>>inform.com;
cout<<" 口试: ";
cin>>inform.oral;
cout<<"确认?(y确认 n重置)";//判断是否正确
cin>>yes1;
if(yes1=='n')continue;

outfile<<inform.name<<" "<<inform.sex<<" "<<inform.age<<" "<<inform.schoolrecord<<" "<<inform.worklen<<" ";
outfile<<inform.pol<<" "<<inform.chn<<" "<<inform.eng<<" "<<inform.com<<" "<<inform.oral<<"\n";

cout<<"\n\n\n需要继续输入吗? (y/n) ";
cin>>yes2;
if(yes2!='y'&& yes2!='Y')mmm=0;
};
cout<<"请输入截至日期:";
cin>>date.year;
cout<<"年";
cin>>date.month;
cout<<"月"<<'\n';
outfile<<"截至日期: "<<date.year<<"年"<<date.month<<"月";

outfile.close();
}
//<invcad.h>(头文件)

//应聘者个人信息struct Tinform
{
char name[9];
char sex[3];
int age;
char schoolrecord[5]; //学历
int worklen; //任科级干部的年限
int pol; //政治
int chn; //语文
int eng; //英语
int com; //计算机
int oral; //口试
float Sage; //年龄分
float Srecord; //学历分
float Swlen; //工龄分
float total; //总分
};
struct Tdate //应聘截止日期
{
int year;
int month;
int date;
};

最后到运行都没有问题,可是在执行时会出现问题,初步认为是treatinf中的数组Tlist1
与export中的数组Tlist不匹配。
大家讨论下,我急着交。。


搜索更多相关主题的帖子: 代码 
2006-07-03 19:53
快速回复:[讨论][求助]源程序代码分析
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015983 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved