C++程序设计课外兴趣小组。急求!!!如果编好的程序满意,加更100分!!!

2024-12-16 07:38:58
推荐回答(5个)
回答1:

你又不给好处谁帮你做啊,悬赏分又不能吃=_=

回答2:

这个一般大家没有那么多时间帮忙整的
年轻人还是自己动手吧
这样多学点

回答3:

给我汇款100元,我还可以考虑考虑

回答4:

策箭酗pogfzywdxh

回答5:

我给你!!!!
记得加分!!!!!
#include
#include
#include
#include
//学生类
class Student{
public:
Student(int stu_no1=-1,char* name1=" ",char* sex1=" ");
~Student();
int stu_no;
char* name;
char* sex;
};
Student::Student(int stu_no1,char* name1,char* sex1)
{
stu_no=stu_no1;
name=new char[strlen(name1)+1];
strcpy(name,name1);
sex=new char[strlen(sex1)+1];
strcpy(sex,sex1);
}
Student::~Student()
{
delete []name;
delete []sex;
}
//兴趣类
class Intrest:public Student{
public:
Intrest(int stu_no1,char* name1,char* sex1,int num1=-1,char* style1=" ");
~Intrest();
int num;
char* style;
};
Intrest::Intrest(int stu_no1,char* name1,char* sex1,int num1,char* style1):Student(stu_no1,name1,sex1)
{
num=num1;
style=new char[strlen(style1)+1];
strcpy(style,style1);
}
Intrest::~Intrest()
{
delete []style;
}
//兴趣类型类
class Kind:public Intrest{
public:
Kind(int stu_no1=-1,char* name1=" ",char* sex1=" ",int num1=-1,char* style1=" "):Intrest(stu_no1,name1,sex1,num1,style1)
{}
void insert();
void modify();
void del();
void show();
void setstu(int stu_no1)
{
stu_no=stu_no1;
}
void setname(char* name1)
{
name=new char[strlen(name1)+1];
strcpy(name,name1);
}
void setsex(char* sex1)
{
sex=new char[strlen(sex1)+1];
strcpy(sex,sex1);
}
void setnum(int num1)
{
num=num1;
}
void setstyle(char* style1)
{
style=new char[strlen(style1)+1];
strcpy(style,style1);
}
static int count;
}stu[100];
int Kind::count=0;
void Kind::insert()
{
cout<<"学生学号:"< cin>>stu_no;
cout<<"学生姓名:"< cin>>name;
cout<<"学生性别:"< cin>>sex;
cout<<"兴趣编号:"< cin>>num;
cout<<"兴趣类型:"< cin>>style;
count++;
}
void Kind::modify()
{
cout<<"+++++请选择要进行的修改:"< cout<<"1...修改学号"< cout<<"2...修改姓名"< cout<<"3...修改性别"< cout<<"4...修改编号"< cout<<"5...修改类型"< cout<<"其它数字键..退出"< int a;
cin>>a;
switch(a)
{
case 1:
cout<<"输入新的学号:"< cin>>stu_no;
break;
case 2:
cout<<"输入新的姓名:"< cin>>name;
break;
case 3:
cout<<"输入新的性别:"< cin>>sex;
break;
case 4:
cout<<"输入新的编号:"< cin>>num;
break;
case 5:
cout<<"输入新的类型:"< cin>>style;
break;
default:
return;
}
}
void Kind::del()
{
stu_no=-1;
name=" ";
sex=" ";
num=-1;
style=" ";
count--;
}
void search()
{
cout<<"输入要查询的学生的学号:"< int r,o=1;
cin>>r;
for(int i=0;i {
if(stu[i].stu_no==r)
{
cout< < < stu[i].show();
o=0;
}
}
if(o==1)
cout<<"没有该学号,查询失败"<}
void Kind::show()
{
cout< < <}
void pri()
{
ofstream fout("学生兴趣小组管理.txt");
if(!fout)
{
cout<<"can not open output file"<
}
fout< < < for(int i=0;i {
fout< < < }
fout.close();
cout<<"保存成功!"< return ;
}
void menu()
{
cout<<"===========学生兴趣小组管理============"< cout<<"1---添加学生兴趣信息"< cout<<"2---修改学生兴趣信息"< cout<<"3---删除学生兴趣信息"< cout<<"4---查询学生兴趣信息"< cout<<"5---显示学生兴趣信息"< cout<<"6---保存数据!!!"< cout<<"其它数字键------退出"<}
void main()
{
for(;;)
{
menu();
cout<<"请选择您要进行的处理:"< int i;
cin>>i;
switch(i)
{
case 1:
cout<<"请输入要添加的学生的人数:"< int i,n;
cin>>n;
for(i=0;i {

stu[Kind::count].insert();
}
if(n==0)
cout<<"无输入!!!"< else
cout<<"输入完毕!!!"< break;
case 2:
cout<<"输入要修改的学生的学号:"< int p;
cin>>p;
for(i=0;i {
if(stu[i].stu_no==p)
{
stu[i].modify();

cout<<"修改成功!!!"< }
}
break;
case 3:
cout<<"输入要删除的学生的学号:"< int q;
cin>>q;
for(i=0;i {
if(stu[i].stu_no==q)
{
stu[i].del();
}
}
for(;i {
Kind temp;
temp=stu[i];
stu[i]=stu[i+1];
stu[i+1]=stu[i];
}
break;
case 4:
search();
break;
case 5:
cout< < < for(i=0;i stu[i].show();
break;
case 6:
pri();
break;
default:
return;
}
}
}