- 博客(0)
- 资源 (6)
- 收藏
- 关注
职工管理系统c 语言版
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
const int N=100;
typedef struct employee//职工基本情况
{
int num;//工号
int position;//职位1为董事长2为总经理3为副总经理等
char name[8];//姓名
char sex[2];//性别f为女m为男
int age;//年龄
int cult;//文化程度1为专家2为博士3为硕士4为学士5为其他
int salary;//工资
int state;//健康情况分为good,general,bad
char day[10];//工作年月
}ro;
ro em[N];
typedef struct communication//职工通讯录
{
char name[8];
char officetel[13];
char hometel[13];
char handtel[13];
char address[13];
char time[13];
}el;
el empc[N];
void manage();
void query();
void communicate();
void input();
void display();
void change();
void del();
void add();
int changeposition();
int changecult();
int changesalary();
int changestate();
void inputcommunicate();
void querycommunicate();
void changecommunicate();
char *changetel1();
char *changetel2();
char *changetel3();
int total;
int p;
char password[10]="talentxch";
void main()
{
int choice;
char s[10];
int flag=0;
int n=3;
do
{
printf("请你输入密码: ");
scanf("%s",s);
if(!strcmp(s,password))//若密码正确
{
printf("恭喜你成功登陆了 ");
flag=1;
break;
}
else
{
printf("输入有错误请重新输入: ");
n--;
}
}while(n>0);
if(!flag)
{
printf("你的输入次数已到再见 ");
}
do
{
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ");
printf(" 欢迎进入职工管理系统中文版 ");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ");
printf(" 请你选择操作类型: ");
printf("====================================================== ");
printf(" 1进入管理系统 ");
printf(" 2进入查询系统 ");
printf(" 3进入通讯录 ");
printf(" 0退出系统 ");
printf("====================================================== ");
scanf("%d",&choice);
switch(choice)
{
case 1:manage();
break;
case 2:query();
break;
case 3:communicate();
break;
case 0:
{
printf("谢谢使用再见 ");
exit(0);
}
default:
{
printf("输入有错误请重新输入: ");
return;
}
}
}while(1);
}
2009-05-11
校园信息管理系弘之模板法
#include <iostream>
#include <fstream>
#include <string>
#include "Class.h"
#define ok 1
#define error 0
void tongji::tsave() //保存统计对象
{
ofstream outfile("statics.dat",ios::out);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
outfile<<tcount<<" ";
outfile<<scount<<" ";
outfile.close();
}
tongji tload() //载入统计对象
{
tongji c;
ifstream infile("statics.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
infile>>c.tcount;
infile>>c.scount;
infile.close();
return (c);
} //
void person::show()const // 输出person
{
cout<<"姓名:"<<name<<endl;
cout<< "性别:"<<sex<<endl;
cout<<"地址:"<<address<<endl;
cout<<"出生日期:"<<year<<"-"<<month<<"-"<<data<<endl;
}
void person::read() //输入person
{
cout<<"姓名:"<<endl;
cin>>name;
cout<<endl;
cout<< "性别:"<<endl;
cin>>sex;
cout<<endl;
cout<<"地址:"<<endl;
cin>>address;
cout<<"出生日期"<<endl;
cout<<"年:";
cin>>year;
cout<<endl;
cout<<"月:" ;
cin>>month;
cout<<endl;
cout<<"日:";
cin>>data;
cout<<endl;
}
void person::load(){};
void Student::show()const //输出学生数据
{
person::show();
cout<<"所在班级:"<<sclass<<endl;
cout<<"所学专业:"<<major<<endl;
cout<<"所学课程:"<<course<<endl;
cout<<"入学日期:"<<sregister<<endl;
}
void Student::read() //读入学生的数据
{
person::read();
cout<<"所在班级:"<<endl;
cin>>sclass;
cout<<endl;
cout<<"所学专业:"<<endl;
cin>>major;
cout<<endl;
cout<<"所学课程:"<<endl;
cin>>course;
cout<<endl;
cout<<"入学日期:"<<endl;
cin>>sregister;
cout<<endl;
}
void Student::save(Student *p) //保存学生的数据
{
ofstream outfile("student.dat",ios::app);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
outfile<<*p;
outfile.close();
}
void Student::load(Student *p) //载入学生数据
{
ifstream infile("student.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
infile>>*p;
infile.close();
}
istream&operator>>(istream&input,Student &stud) //重载cin
{
input>>stud.name;
input>>stud.sex;
input>>stud.address;
input>>stud.year;
input>>stud.month;
input>>stud.data;
input>>stud.sclass;
input>>stud.major;
input>>stud.course;
input>>stud.sregister;
return input;
}
ostream&operator<<(ostream&output,Student &stud) //重载cout
{
output<<stud.name<<endl;
output<<stud.sex<<endl;
output<<stud.address<<endl;
output<<stud.year<<endl;
output<<stud.month<<endl;
output<<stud.data<<endl;
output<<stud.sclass<<endl;
output<<stud.major<<endl;
output<<stud.course<<endl;
output<<stud.sregister<<endl;
return output;
}
istream&operator>>(istream&input,Teacher &t) //重载cin
{
input>>t.name;
input>>t.sex;
input>>t.address;
input>>t.year;
input>>t.month;
input>>t.data;
input>>t.course;
input>>t.tregister;
return input;
}
ostream&operator<<(ostream&output,Teacher &t) //重载cout
{
output<<t.name<<endl;
output<<t.sex<<endl;
output<<t.address<<endl;
output<<t.year<<endl;
output<<t.month<<endl;
output<<t.data<<endl;
output<<t.course<<endl;
output<<t.tregister<<endl;
return output;
} //输出教师
void Teacher::show()const
{
person::show();
cout<<"所教课程:"<<course<<endl;
cout<<"开学时间:"<<tregister<<endl;
}
void Teacher::read() //输人教师
{
person::read();
cout<<"所教课程:";
cin>>course;
cout<<endl;
cout<<"开学时间:";
cin>>tregister;
cout<<endl;
}
void Teacher::save(Teacher *p) //保存教师
{
ofstream outfile("teacher.dat",ios::app);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
outfile<<*p;
outfile.close();
}
void Teacher::load(Teacher*p) //载入教师
{
ifstream infile("teacher.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
infile>>*p;
infile.close();
}//teacher
typedef struct Snode
{
Student data;
struct Snode *next;
}Snode,*SLinklist; //学生结点
//void Createlist_l(Snode &SL,int n,Student &ps)
//{
//int i;
//Snode *p;
//SL=(SLinklist)malloc(sizeof(Snode));
//SL->next=NULL;
//for(i=n;i>0;--i)
//{
// p=(SLinklist)malloc(sizeof(Snode));
//p->data=ps;
//p->next=SL->next;
//SL->next=p;
// }
// return SL;
//}//创建学生链表
int SlisTdelete_L(SLinklist &SL,int i) //删除学生链表
{
Snode *p,*q;
int j=1;
p=SL;
while(p->next&&j<i-1)
{
p=p->next;
++j;
}
if(!(p->next)||j>i-1)
return error;
q= p->next;
p->next=q->next;
free(q);
//scount--;
return ok;
}
typedef struct Tnode
{
Teacher data;
struct Tnode *next;
}Tnode,*TLinklist; //老师结点
void Createlist_l(TLinklist &TL,int n,Teacher &pt)
{
int i;
Tnode *p;
TL=(TLinklist)malloc(sizeof(Tnode));
TL->next=NULL;
for(i=n;i>0;--i)
{
p=(TLinklist)malloc(sizeof(Tnode));
p->data=pt;
p->next=TL->next;
TL->next=p;
}
} //创建老师链表
int TlisTdelete_L(TLinklist &TL,int i)
{
Tnode *p,*q;
int j=1;
p=TL;
while(p->next&&j<i-1)
{
p=p->next;
++j;
}
if(!(p->next)||j>i-1)
return error;
q= p->next;
p->next=q->next;
free(q);
//tcount--;
return ok;
} //删除老师链表
void input() //选择操作
{
cout<<"请选择是要输入学生的数据还是老师的?"<<endl;
cout<<"a.学生"<<endl;
cout<<"b.老师"<<endl;
string n;
string m;
cin>>n;
tongji c;
ifstream infile("statics.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
tongji *p=new tongji;
infile>>p->tcount;
infile>>p->scount;
infile.close();
if(n=="a")
{
Student *ps=new Student;
ps->read();
cout<<"是否保存在文件中,y/n?"<<endl;
cin>>m;
if(m=="y")
{
ps->save(ps);
cout << " 成功保存数据!";
delete ps;
p->scount=p->scount+1;
p->tsave();
}
}
else if(n=="b")
{
Teacher *pt=new Teacher;
pt->read();
cout<<"是否保存在文件中,y/n?"<<endl;
cin>>m;
if(m=="y")
{
pt->save(pt);
cout << "成功保存数据!" ;
delete pt;
p->tcount=p->tcount+1;
p->tsave();
}
}
else cout<<"你的输入有错!"<<endl;
} //输入(插入)学生或老师数据
void output()
{
int i,j;
char m;
cout<<"请选择是要输出学生的数据还是老师的?"<<endl;
cout<<"a.学生"<<endl;
cout<<"b.老师"<<endl;
cin>>m;
ifstream infile("statics.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
tongji *pj=new tongji;
infile>>pj->tcount;
infile>>pj->scount;
if(m=='a')
{
ifstream infile("student.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
int j;
for(j=1;j<=pj->scount;j++)
{
Student *p=new Student;
infile>>p->name;
infile>>p->sex;
infile>>p->address;
infile>>p->year;
infile>>p->month;
infile>>p->data;
infile>>p->sclass;
infile>>p->major;
infile>>p->course;
infile>>p->sregister;
p->show();
delete p;
}
infile.close();
}
else if(m=='b')
{
ifstream infile("teacher.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
int j;
for(j=1;j<=pj->tcount;j++)
{
Teacher *TL=new Teacher;
infile>>TL->name;
infile>>TL->sex;
infile>>TL->address;
infile>>TL->year;
infile>>TL->month;
infile>>TL->data;
infile>>TL->course;
infile>>TL->tregister;
TL->show();
delete(TL);
}
infile.close();
}
else cout<<"你的输入有错!"<<endl;
} //输出学生或老师数据
void deleted()
{
string m;
cout<<"你想要删除有关老师的信息还是学生?"<<endl;
cout<<"a.学生"<<endl;
cout<<"b.老师"<<endl;
cin>>m;
ifstream infile("statics.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
tongji *pj=new tongji;
infile>>pj->tcount;
infile>>pj->scount;
if(m=="a")
{
string mz;
int sflag=0;
int j;
Snode *l=new Snode; //建立一个学生的空链表
l->next=NULL; Snode *p=l;
//等下可先存放在stu中
cout<<"请输入你想删除的学生的名字:";
cin>>mz;
ifstream infile("student.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(j=1;j<=pj->scount;j++)
{
Snode *ps=new Snode;
infile>>ps->data.name;
infile>>ps->data.sex;
infile>>ps->data.address;
infile>>ps->data.year;
infile>>ps->data.month;
infile>>ps->data.data;
infile>>ps->data.sclass;
infile>>ps->data.major;
infile>>ps->data.course;
infile>>ps->data.sregister;
if(mz==ps->data.name)sflag=j+1;
p->next=ps; ps->next=NULL;
p=p->next;
// ps->next=l->next; //学生的链表
// l->next=ps;
}
infile.close();
Snode *ps;
if(sflag!=0)
{
SlisTdelete_L(l,sflag);
ps=l->next;
pj->scount=pj->scount-1;
cout<<"删除后的其他学生的资料如下:"<<endl;
for(j=1;j<=pj->scount;j++)
{
ps->data.show();
ps=ps->next;
}
char t;
cout<<"是否保存在student.dat中y/n?"<<endl;
cin>>t;
if(t=='y')
{ //7
pj->tsave();
ofstream outfile("student.dat",ios::out);
if(!outfile)
{//8
cerr<<"open error!"<<endl;
exit(1);
}//8
ps=l->next;
for(j=1;j<=pj->scount;j++)
{
ps->data.save(&(ps->data));
ps=ps->next;
pj->tsave();
}
outfile.close();
cout<<"保存成功!"<<endl;
}
}
else cout<<"此人不存在!"<<endl;
}//3
else if(m=="b")
{
string mz;
int tflag=0;
int j;
Tnode *l=new Tnode; Tnode* p=l;
l->next=NULL; //建立一个老师的空链表
cout<<"请输入你想删除的老师的名字:";
cin>>mz;
ifstream infile("teacher.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(j=1;j<=pj->tcount;j++)
{
Tnode *pt=new Tnode;
infile>>pt->data.name;
infile>>pt->data.sex;
infile>>pt->data.address;
infile>>pt->data.year;
infile>>pt->data.month;
infile>>pt->data.data;
infile>>pt->data.course;
infile>>pt->data.tregister;
if(mz==pt->data.name)tflag=j+1;
p->next=pt; pt->next=NULL;
p=p->next;
// pt->next=l->next; //建立老师的链表
//l->next=pt;
}
infile.close();
Tnode *pt;
if(tflag!=0)
{
//for(j=tflag;j<=pj->tcount;j++)teach[j]=teach[j+1];
TlisTdelete_L(l,tflag);
// pj->tcount= (pj->tcount)-1;
pt=l->next;
pj->tcount=pj->tcount-1;
cout<<"删除后的其他老师的资料如下:"<<endl;
for(j=1;j<=pj->tcount;j++)
{
pt->data.show();
pt=pt->next;
}
//teach[j].show();
char t;
cout<<"是否保存在teacher.dat中y/n?"<<endl;
cin>>t;
if(t=='y')
{
pj->tsave();
ofstream outfile("teacher.dat",ios::out);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
pt=l->next;
for(j=1;j<=pj->tcount;j++)
{
pt->data.save(&(pt->data));
pt=pt->next;
pj->tsave();
}
outfile.close();
cout<<"保存成功!"<<endl;
}
}
else cout<<"此人不存在!"<<endl;
}
else cout<<"你的输入有误!"<<endl;
} //删除数据功能
void search()
{
cout<<"请选择你想查找的对象:"<<endl;
cout<<"a.学生"<<endl;
cout<<"b.老师"<<endl;
string m;
string mz;
ifstream infile("statics.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
tongji *pj=new tongji;
infile>>pj->tcount;
infile>>pj->scount;
cin>>m;
if(m=="a")
{
Snode *l=new Snode; //建立一个学生的空链表
l->next=NULL;
cout<<"请输入你想查找的学生的名字:";
cin>>mz;
int sflag=0;
ifstream infile("student.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
int j;
for(j=1;j<=pj->scount;j++)
{
Snode *ps=new Snode;
infile>>ps->data.name;
infile>>ps->data.sex;
infile>>ps->data.address;
infile>>ps->data.year;
infile>>ps->data.month;
infile>>ps->data.data;
infile>>ps->data.sclass;
infile>>ps->data.major;
infile>>ps->data.course;
infile>>ps->data.sregister;
ps->next=l->next; //建立老师的链表
l->next=ps;
if(ps->data.name==mz){ps->data.show();sflag=1;}
//delete p;
}
infile.close();
if(sflag==0)cout<<"不存在此人!"<<endl;
}
//查找学生的资料
else if(m=="b")
{
Tnode *l=new Tnode;
l->next=NULL; //建立一个老师的空链表
string mz;
int j;
int tflag=0;
cout<<"请输入你想查找的老师的名字:";
cin>>mz;
ifstream infile("teacher.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(j=1;j<=pj->tcount;j++)
{
Tnode *p=new Tnode;
infile>>p->data.name;
infile>>p->data.sex;
infile>>p->data.address;
infile>>p->data.year;
infile>>p->data.month;
infile>>p->data.data;
infile>>p->data.course;
infile>>p->data.tregister;
p->next=l->next; //建立老师的链表
l->next=p;
if(p->data.name==mz){p->data.show();tflag=1;}
//delete p;
}
infile.close();
if(tflag==0) cout<<"不存在此人!"<<endl;
} //查找老师的资料
else cout<<"你的输入有错!"<<endl ;
} //查找功能
void change()
{
cout<<"请选择修改的对象:"<<endl;
cout<<"a.学生"<<endl;
cout<<"b.老师"<<endl;
string m;
cin>>m;
ifstream infile("statics.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
tongji *p=new tongji;
infile>>p->tcount;
infile>>p->scount;
if(m=="a")
{
int sflag=0;
Snode *l=new Snode; //建立一个学生的空链表
l->next=NULL;
//Student stu[100];//存放学生数据
cout<<"请输入你想修改学生的名字:"<<endl;
string mz;
int j;
cin>>mz;
ifstream infile("student.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(j=1;j<=p->scount;j++)
{
Snode *ps=new Snode;
infile>>ps->data.name;
infile>>ps->data.sex;
infile>>ps->data.address;
infile>>ps->data.year;
infile>>ps->data.month;
infile>>ps->data.data;
infile>>ps->data.sclass;
infile>>ps->data.major;
infile>>ps->data.course;
infile>>ps->data.sregister;
if(ps->data.name==mz) //找到该学生并修改其相应的数据
{
sflag=1;
cout<<"姓名:"<<endl;
cin>>ps->data.name;
cout<<endl;
cout<< "性别:"<<endl;
cin>>ps->data.sex;
cout<<endl;
cout<<"地址:"<<endl;
cin>>ps->data.address;
cout<<"出生日期"<<endl;
cout<<"年:";
cin>>ps->data.year;
cout<<endl;
cout<<"月:" ;
cin>>ps->data.month;
cout<<endl;
cout<<"日:";
cin>>ps->data.data;
cout<<endl;
cout<<"所在班级:"<<endl;
cin>>ps->data.sclass;
cout<<endl;
cout<<"所学专业:"<<endl;
cin>>ps->data.major;
cout<<endl;
cout<<"所学课程:"<<endl;
cin>>ps->data.course;
cout<<endl;
cout<<"入学日期:"<<endl;
cin>>ps->data.sregister;
cout<<endl;
}
ps->next=l->next; //建立学生的链表
l->next=ps;
}
if(sflag==0) cout<<"系统中找不到你想找的人!"<<endl;
else
{
Snode *ps=new Snode;
ps=l->next;
cout<<"是否保存修改的数据到student.dat中?y/n"<<endl;
string t;
cin>>t;
if(t=="y")
{
ofstream outfile("student.dat",ios::out);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(j=1;j<=p->scount;j++)
{
outfile<<ps->data.name<<" ";
outfile<<ps->data.sex<<" ";
outfile<<ps->data.address<<" ";
outfile<<ps->data.year<<" ";
outfile<<ps->data.month<<" ";
outfile<<ps->data.data<<" ";
outfile<<ps->data.sclass<<" ";
outfile<<ps->data.major<<" ";
outfile<<ps->data.course<<" ";
outfile<<ps->data.sregister<<" ";
ps=ps->next;
}
}
}
}
else if(m=="b")
{
Tnode *l=new Tnode;
l->next=NULL; //建立一个老师的空链表
cout<<"请输入你想修改老师的名字:"<<endl;
string tt;
int j;
int tflag=0;
cin>>tt;
ifstream infile("teacher.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(j=1;j<=p->tcount;j++)
{
Tnode *p=new Tnode;
infile>>p->data.name;
infile>>p->data.sex;
infile>>p->data.address;
infile>>p->data.year;
infile>>p->data.month;
infile>>p->data.data;
infile>>p->data.course;
infile>>p->data.tregister;
if(p->data.name==tt) //找到该老师并修改其相应的数据
{
tflag=1;
cout<<"姓名:"<<endl;
cin>>p->data.name;
cout<<endl;
cout<< "性别:"<<endl;
cin>>p->data.sex;
cout<<endl;
cout<<"地址:"<<endl;
cin>>p->data.address;
cout<<"出生日期"<<endl;
cout<<"年:";
cin>>p->data.year;
cout<<endl;
cout<<"月:" ;
cin>>p->data.month;
cout<<endl;
cout<<"日:";
cin>>p->data.data;
cout<<endl;
cout<<"所教课程:";
cin>>p->data.course;
cout<<endl;
cout<<"开学时间:";
cin>>p->data.tregister;
cout<<endl;
}
p->next=l->next; //建立老师的链表
l->next=p;
}
if(tflag==0) cout<<"系统中找不到你想找的人!"<<endl;
else
{
Tnode *pt=new Tnode;
pt=l->next;
cout<<"是否保存修改的数据到teacher.dat中?y/n"<<endl;
string t;
cin>>t;
if(t=="y")
{
ofstream outfile("teacher.dat",ios::out);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(j=1;j<=p->tcount;j++)
{
outfile<<pt->data.name<<" ";
outfile<<pt->data.sex<<" ";
outfile<<pt->data.address<<" ";
outfile<<pt->data.year<<" ";
outfile<<pt->data.month<<" ";
outfile<<pt->data.data<<" ";
outfile<<pt->data.course<<" ";
outfile<<pt->data.tregister<<" ";
pt=pt->next;
}
}
}
}
else cout<<"你的输入有误!"<<endl;
}
void rank() //排列数据
{
cout<<"请选择排列的对象:"<<endl;
cout<<"a.学生"<<endl;
cout<<"b.老师"<<endl;
string m;
cin>>m;
tongji *pj=new tongji;
*pj=tload();
if(m=="a") //排列学生
{
Student stu[100];
ifstream infile("student.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
int j,i;
Student p;
for(j=1;j<=pj->scount;j++)
{
infile>>stu[j].name;
infile>>stu[j].sex;
infile>>stu[j].address;
infile>>stu[j].year;
infile>>stu[j].month;
infile>>stu[j].data;
infile>>stu[j].sclass;
infile>>stu[j].major;
infile>>stu[j].course;
infile>>stu[j].sregister;
}
infile.close();
for(j=1;j<=pj->scount;j++)
for(i=1;i<=(pj->scount)-j;i++)
if(stu[i].name>stu[i+1].name)
{
p=stu[i];
stu[i]=stu[i+1];
stu[i+1]=p;
}
cout<<"排列后的各个学生的数据如下(按名字的头个字母小到大排列):"<<endl;
for(j=1;j<=pj->scount;j++)
stu[j].show();
cout<<"是否要保存排列的数据,y/n?"<<endl;
string m;
cin>>m;
if(m=="y")
{
ofstream outfile("student.dat",ios::out);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(j=1;j<=pj->scount;j++)
{
stu[j].save(&stu[j]);
}
}
}
else if(m=="b") //排列老师
{
Teacher teach[100];
ifstream infile("teacher.dat",ios::in);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
int j,i;
Teacher p;
for(j=1;j<=pj->tcount;j++)
{
infile>>teach[j].name;
infile>>teach[j].sex;
infile>>teach[j].address;
infile>>teach[j].year;
infile>>teach[j].month;
infile>>teach[j].data;
infile>>teach[j].course;
infile>>teach[j].tregister;
}
infile.close();
for(j=1;j<=pj->tcount;j++)
for(i=1;i<=(pj->tcount)-j;i++)
if(teach[i].name>teach[i+1].name)
{
p=teach[i];
teach[i]=teach[i+1];
teach[i+1]=p;
}
cout<<"排列后的各个老师的数据如下(按名字的头个字母小到大排列):"<<endl;
for(j=1;j<=pj->tcount;j++)
teach[j].show();
cout<<"是否要保存排列的数据,y/n?"<<endl;
string m;
cin>>m;
if(m=="y")
{
ofstream outfile("teacher.dat",ios::out);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
for(j=1;j<=pj->tcount;j++)
{
teach[j].save(&teach[j]);
}
}
}
else cout<<"你的输入有错!"<<endl;
} //排列功能
2009-05-11
校园信息管理系统之容器法
#include <iostream>
#include <fstream>
#include "head.h"
//---------------------------------------
long Student::returnsort(){return id;}
void Student::show()
{
cout<<"*************************"<<endl;
cout<<"编号:"<<id<<endl;
cout<<"姓名:"<<name<<endl;
cout<<"性别:"<<sex<<endl;
cout<<"家庭地址:"<<address<<endl;
cout<<"出生日期:"<<date.year<<"-"<<date.month<<"-"<<date.day<<endl;
cout<<"所在班级:"<<sclass<<endl;
cout<<"所学专业:"<<major<<endl;
cout<<"所学课程:"<<courses<<endl;
cout<<"入学时间:"<<sregister.year<<"-"<<sregister.month<<"-"<<sregister.day<<endl;;
}
void Student::read()
{
cout<<"编号:"<<endl;cin>>id;
cout<<"姓名:"<<endl;cin>>name;
cout<<"性别:"<<endl;cin>>sex;
cout<<"家庭地址:"<<endl;cin>>address;
cout<<"出生日期:"<<endl;
cout<<"年:"<<endl;cin>>date.year;
cout<<"月:"<<endl;cin>>date.month;
cout<<"日:"<<endl;cin>>date.day;
cout<<"所在班级:"<<endl; cin>>sclass;
cout<<"所学专业"<<endl;cin>>major;
cout<<"所学课程"<<endl;cin>>courses;
cout<<"入学日期:"<<endl;
cout<<"年:";cin>>sregister.year;
cout<<"月:";cin>>sregister.month;
cout<<"日";cin>>sregister.day;
}
void Student::load()
{
Student stud;
ifstream infile("student.txt",ios::in|ios::binary);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
infile.read((char *)&stud,sizeof(stud));
infile.close();
}
void Student::save()
{
Student stud;
stud.read();
ofstream outfile("student.txt",ios::app|ios::binary);
if(!outfile)
{
cerr<<"error"<<endl;
exit(1);
}
outfile.write((char *)&stud,sizeof(stud));
outfile.close();
}
istream& operator >> (istream& input,Student& c)//运算符">>"重载为友元函数
{
cout<<"编号:"<<endl;input>>c.id; cout<<endl;
cout<<"姓名:"<<endl;input>>c.name; cout<<endl;
cout<<"性别:"<<endl;input>>c.sex; cout<<endl;
cout<<"家庭地址:"<<endl;input>>c.address; cout<<endl;
cout<<"出生日期:"<<endl;
cout<<"年:";input>>c.date.year;
cout<<"月:";input>>c.date.month;
cout<<"日:";input>>c.date.day; cout<<endl;
cout<<"入学日期:"<<endl;
cout<<"年:";input>>c.sregister.year;
cout<<"月:";input>>c.sregister.month;
cout<<"日:";input>>c.sregister.day; cout<<endl;
cout<<"所在班级:"<<endl;input>>c.sclass; cout<<endl;
cout<<"所学专业:"<<endl;input>>c.major; cout<<endl;
cout<<"所学课程:"<<endl;input>>c.courses; cout<<endl;
return input;
}
ostream& operator << (ostream& output,Student& c)//运算符"<<"重载为友元函数
{
output<<"编号:"<<c.id<<endl;
output<<"姓名:"<<c.name<<endl;
output<<"性别:"<<c.sex<<endl;
output<<"家庭地址:"<<c.address<<endl;
output<<"出生日期:"<<c.date.year<<"-"<<c.date.month<<"-"<<c.date.day<<endl;
output<<"入学日期:"<<c.sregister.year<<"-"<<c.sregister.month<<"-"<<c.sregister.day<<endl;
output<<"所在班级:"<<c.sclass<<endl;
output<<"所学专业:"<<c.major<<endl;
output<<"所学课程:"<<c.courses<<endl;
return output;
}
bool operator >(Student& c1,Student& c2)//重载运算符">"
{
if(c1.id>c2.id) return true;
else return false;
}
bool operator ==(Student &c1,Student &c2)//重载运算符"=="
{
if(c1.id==c2.id) return true;
else return false;
}
//--------------------------------------
long Teacher::returnsort(){return id;}
void Teacher::show()
{
cout<<"编号:"<<id<<endl;
cout<<"姓名:"<<name<<endl;
cout<<"性别:"<<sex<<endl;
cout<<"家庭住址:"<<address<<endl;
cout<<"出生日期:"<<date.year<<"-"<<date.month<<"-"<<date.day<<endl;
cout<<"所教课程:"<<courses<<endl;
cout<<"到校时间:"<<tregister.year<<"-"<<tregister.month<<"-"<<tregister.day<<endl;
}
void Teacher::read()
{
cout<<"编号:"<<endl;cin>>id;
cout<<"姓名:"<<endl;cin>>name;
cout<<"性别:"<<endl;cin>>sex;
cout<<"家庭地址:"<<endl;cin>>address;
cout<<"出生日期:"<<endl;
cout<<"年:";cin>>date.year;
cout<<"月:";cin>>date.month;
cout<<"日:";cin>>date.day;
cout<<"所教课程:"<<endl;cin>>courses;
cout<<"到校日期:"<<endl;
cout<<"年:";cin>>tregister.year;
cout<<"月:";cin>>tregister.month;
cout<<"日";cin>>tregister.day;
}
void Teacher::load()
{
Teacher teac;
ifstream infile("teacher.txt",ios::in|ios::binary);
if(!infile)
{
cerr<<"open error!"<<endl;
exit(1);
}
infile.read((char *)&teac,sizeof(teac));
teac.show();
infile.close();
}
void Teacher::save()
{
Teacher teac;
teac.read();
ofstream outfile("teacher.txt",ios::app|ios::binary);
if(!outfile)
{
cerr<<"error"<<endl;
exit(1);
}
outfile.write((char *)&teac,sizeof(teac));
outfile.close();
}
istream & operator >> (istream &input,Teacher &c)//运算符">>"重载为友元函数
{
cout<<"编号:"<<endl;input>>c.id; cout<<endl;
cout<<"姓名:"<<endl;input>>c.name; cout<<endl;
cout<<"性别:"<<endl;input>>c.sex; cout<<endl;
cout<<"家庭地址:"<<endl;input>>c.address; cout<<endl;
cout<<"出生日期:"<<endl;
cout<<"年:";input>>c.date.year;
cout<<"月:";input>>c.date.month;
cout<<"日:";input>>c.date.day; cout<<endl;
cout<<"到校日期:"<<endl;
cout<<"年:";input>>c.tregister.year;
cout<<"月:";input>>c.tregister.month;
cout<<"日:";input>>c.tregister.day; cout<<endl;
cout<<"所教课程:"<<endl;input>>c.courses; cout<<endl;
return input;
}
ostream & operator << (ostream &output,Teacher &c)//运算符"<<"重载为友元函数
{
output<<"编号:"<<c.id<<endl;
output<<"姓名:"<<c.name<<endl;
output<<"性别:"<<c.sex<<endl;
output<<"家庭地址:"<<c.address<<endl;
output<<"出生日期:"<<c.date.year<<"-"<<c.date.month<<"-"<<c.date.day<<endl;
output<<"到校时间:"<<c.tregister.year<<"-"<<c.tregister.month<<"-"<<c.tregister.day<<endl;
output<<"所教课程:"<<c.courses<<endl;
}
bool operator >(Teacher &c1,Teacher &c2)//重载运算符">"
{
if(c1.id>c2.id) return true;
else return false;
}
bool operator ==(Teacher &c1,Teacher &c2)//重载运算符"=="
{
if(c1.id==c2.id) return true;
else return false;
}
2009-05-11
校园信息管理系统之链表法
#include<iostream>
#include<string>
using namespace std;
class Student{
private:
typedef struct student{
string num;
string name;
string sex;
string address;
string birthday;
string sclass;
string major;
string sregister;
struct student *next;
}node;
typedef node *link;
link stu;
public:
void Show();
void Read();
long Save();
void Load();
void Insert();
void Delete();
void Sort();
void Change();
void Query();
friend istream &operator>>(istream &,Student::student &);
friend ostream &operator<<(ostream &,Student::student &);
};
class Teacher{
private:
typedef struct teacher{
string name;
string sex;
string address;
string birthday;
string course;
string tregister;
struct teacher *next;
}Node;
typedef Node *Link;
Link tea;
public:
void Show();
void Read();
long Save();
void Load();
void Insert();
void Delete();
void Change();
void Query(); //教师排序功能不实现
friend istream &operator>>(istream &,Teacher::teacher &);
friend ostream &operator<<(ostream &,Teacher::teacher &);
};
class CMDOrder{
public:
bool helpCMD();
bool inputCMD();
bool outputCMD();
bool saveCMD();
bool loadCMD();
bool analyzeCMD();
bool exitCMD();
};
2009-05-11
防护arp攻击软件最终版-Antiarp安全软件
防护arp攻击软件最终版-Antiarp安全软件
使用方法:
1、填入网关IP地址,点击〔获取网关地址〕将会显示出网关的MAC地址。点击[自动防护]即可保护当前网卡与该网关的通信不会被第三方监听。注意:如出现这种欺骗提示,这说明攻击者发送了对于此种欺骗数据包来获取网卡的数据包,如果您想追踪攻击来源请记住攻击者的MAC地址,利用MAC地址扫描器可以找出IP 对应的MAC地址.
2、IP地址冲突
如频繁的出现IP地址冲突,这说明攻击者频繁发送ARP欺骗数据包,才会出现IP冲突的警告,利用Anti ARP Sniffer可以防止此类攻击。
3、您需要知道冲突的MAC地址,Windows会记录这些错误。查看具体方法如下:
右击[我的电脑]--[管理]--点击[事件查看器]--点击[系统]--查看来源为[TcpIP]---双击事件可以看到显示地址发生冲突,并记录了该MAC地址,请复制该MAC地址并填入Anti ARP Sniffer的本地MAC地址输入框中(请注意将:转换为-),输入完成之后点击[防护地址冲突],为了使M地址生效请禁用本地网卡然后再启用网卡,在CMD命令行中输入Ipconfig /all,查看当前MAC地址是否与本地MAC地址输入框中的地址相符,如果更改失败请与我联系。如果成功将不再会显示地址冲突。
注意:如果您想恢复默认MAC地址,请点击[恢复默认],为了使地址生效请禁用本地网卡然后再启用网卡。
有关ARP病毒问题的处理说明:
故障现象 :机器以前可正常上网的,突然出现可认证,不能上网的现象(无法ping通网关),重启机器或在MSDOS窗口下运行命令ARP -d后,又可恢复上网一段时间。
故障原因:这是APR病毒欺骗攻击造成的。
引起问题的原因一般是由传奇外挂携带的ARP木马攻击。当在局域网内使用上述外挂时,外挂携带的病毒会将该机器的MAC地址映射到网关的IP地址上,向局域网内大量发送ARP包,从而致使同一网段地址内的其它机器误将其作为网关,这就是为什么掉线时内网是互通的,计算机却不能上网的原因。
临时处理对策:
步骤一. 在能上网时,进入MS-DOS窗口,输入命令:arp –a 查看网关IP对应的正确MAC地址,将其记录下来。
注:如果已经不能上网,则先运行一次命令arp –d将arp缓存中的内容删空,计算机可暂时恢复上网(攻击如果不停止的话),一旦能上网就立即将网络断掉(禁用网卡或拔掉网线),再运行arp –a。
步骤二. 如果已经有网关的正确MAC地址,在不能上网时,手工将网关IP和正确MAC绑定,可确保计算机不再被攻击影响。手工绑定可在MS-DOS窗口下运行以下命令: arp –s 网关IP 网关MAC
例如:假设计算机所处网段的网关为218.197.192.254,本机地址为218.197.192.1在计算机上运行arp –a后输出如下:
C:\Documents and Settings>arp -a
Interface: 218.197.192.1 --- 0x2
Internet Address Physical Address Type
218.197.192.254 00-01-02-03-04-05 dynamic
其中00-01-02-03-04-05就是网关218.197.192.254对应的MAC地址,类型是动态(dynamic)的,因此是可被改变。
被攻击后,再用该命令查看,就会发现该MAC已经被替换成攻击机器的MAC,如果大家希望能找出攻击机器,彻底根除攻击,可以在此时将该MAC记录下来,为以后查找做准备。
手工绑定的命令为:
arp –s 218.197.192.254 00-01-02-03-04-05
绑定完,可再用arp –a查看arp缓存,
C:\Documents and Settings>arp -a
Interface: 218.197.192.1 --- 0x2
Internet Address Physical Address Type
218.197.192.254 00-01-02-03-04-05 static
这时,类型变为静态(static),就不会再受攻击影响了。但是,需要说明的是,手工绑定在计算机关机重开机后就会失效,需要再绑定。所以,要彻底根除攻击,只有找出网段内被病毒感染的计算机,令其杀毒,方可解决。找出病毒计算机的方法:
如果已有病毒计算机的MAC地址,可使用NBTSCAN软件找出网段内与该MAC地址对应的IP,即病毒计算机的IP地址,然后可报告校网络中心对其进行查封。
2009-05-07
内存工作原理之内存寻址 内存传输 存取时间 内存延迟
内存工作原理
1.内存寻址
首先,内存从CPU获得查找某个数据的指令,然后再找出存取资料的位置时(这个动作称为“寻址”),它先定出横坐标(也就是“列地址”)再定出纵坐标(也就是“行地址”),这就好像在地图上画个十字标记一样,非常准确地定出这个地方。对于电脑系统而言,找出这个地方时还必须确定是否位置正确,因此电脑还必须判读该地址的信号,横坐标有横坐标的信号(也就是RAS信号,Row Address Strobe)纵坐标有纵坐标的信号(也就是CAS信号,Column Address Strobe),最后再进行读或写的动作。因此,内存在读写时至少必须有五个步骤:分别是画个十字(内有定地址两个操作以及判读地址两个信号,共四个操作)以及或读或写的操作,才能完成内存的存取操作。
2.内存传输
为了储存资料,或者是从内存内部读取资料,CPU都会为这些读取或写入的资料编上地址(也就是我们所说的十字寻址方式),这个时候,CPU会通过地址总线(Address Bus)将地址送到内存,然后数据总线(Data Bus)就会把对应的正确数据送往微处理器,传回去给CPU使用。
3.存取时间
所谓存取时间,指的是CPU读或写内存内资料的过程时间,也称为总线循环(bus cycle)。以读取为例,从CPU发出指令给内存时,便会要求内存取用特定地址的特定资料,内存响应CPU后便会将CPU所需要的资料送给CPU,一直到CPU收到数据为止,便成为一个读取的流程。因此,这整个过程简单地说便是CPU给出读取指令,内存回复指令,并丢出资料给CPU的过程。我们常说的6ns(纳秒,秒-9)就是指上述的过程所花费的时间,而ns便是计算运算过程的时间单位。我们平时习惯用存取时间的倒数来表示速度,比如6ns的内存实际频率为1/6ns=166MHz(如果是DDR就标DDR333,DDR2就标DDR2 667)。
4.内存延迟
内存的延迟时间(也就是所谓的潜伏期,从FSB到DRAM)等于下列时间的综合:FSB同主板芯片组之间的延迟时间(±1个时钟周期),芯片组同DRAM之间的延迟时间(±1个时钟周期),RAS到CAS延迟时间:RAS(2-3个时钟周期,用于决定正确的行地址),CAS延迟时间 (2-3时钟周期,用于决定正确的列地址),另外还需要1个时钟周期来传送数据,数据从DRAM输出缓存通过芯片组到CPU的延迟时间(±2个时钟周期)。一般的说明内存延迟涉及四个参数CAS(Column Address Strobe 行地址控制器)延迟,RAS(Row Address Strobe列地址控制器)-to-CAS延迟,RAS Precharge(RAS预冲电压)延迟,Act-to-Precharge(相对于时钟下沿的数据读取时间)延迟。其中CAS延迟比较重要,它反映了内存从接受指令到完成传输结果的过程中的延迟。大家平时见到的数据3—3—3—6中,第一参数就是CAS延迟(CL=3)。当然,延迟越小速度越快。
2009-05-07
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人