#include<iostream.h>
const int Maxsize=100;
class Student
{
public:
Student(){}
Student(int ,char *,int ,float);
~Student(){};
int Getcount(){return count;}
void Insert(int i,char *a,int b,float c);
void Delete(int i);
void get(int i);
void Print();
private:
int count;
char *name[Maxsize];
int age[Maxsize];
float sorce[Maxsize];
};
Student::Student(int i,char *a,int b,float c)
{
name[i]=a;
age[i]=b;
sorce[i]=c;
count=i;
}
void Student::Insert(int i,char *a,int b,float c)
{
for(int j=count;j>=i;j--)
{
name[j+1]=name[j];
age[j+1]=age[j];
sorce[j+1]=sorce[j];
}
name[i]=a;
age[i]=b;
sorce[i]=c;
count++;
}
void Student::Delete(int i)
{
for(int j=i;j<count;j++)
{
name[j]=name[j+1];
age[j]=age[j+1];
sorce[j]=sorce[j+1];
}
count--;
}
void Student::get(int i)
{
if(i>count&&i<0)
cout<<"输入序号有误"<<endl;
cout<<name[i]<<" "<<age[i]<<" "<<sorce[i]<<endl;
}
void Student::Print()
{
for(int i=0;i<=count;i++)
cout<<name[i]<<" "<<age[i]<<" "<<sorce[i]<<endl;
}
const int Maxsize=100;
class Student
{
public:
Student(){}
Student(int ,char *,int ,float);
~Student(){};
int Getcount(){return count;}
void Insert(int i,char *a,int b,float c);
void Delete(int i);
void get(int i);
void Print();
private:
int count;
char *name[Maxsize];
int age[Maxsize];
float sorce[Maxsize];
};
Student::Student(int i,char *a,int b,float c)
{
name[i]=a;
age[i]=b;
sorce[i]=c;
count=i;
}
void Student::Insert(int i,char *a,int b,float c)
{
for(int j=count;j>=i;j--)
{
name[j+1]=name[j];
age[j+1]=age[j];
sorce[j+1]=sorce[j];
}
name[i]=a;
age[i]=b;
sorce[i]=c;
count++;
}
void Student::Delete(int i)
{
for(int j=i;j<count;j++)
{
name[j]=name[j+1];
age[j]=age[j+1];
sorce[j]=sorce[j+1];
}
count--;
}
void Student::get(int i)
{
if(i>count&&i<0)
cout<<"输入序号有误"<<endl;
cout<<name[i]<<" "<<age[i]<<" "<<sorce[i]<<endl;
}
void Student::Print()
{
for(int i=0;i<=count;i++)
cout<<name[i]<<" "<<age[i]<<" "<<sorce[i]<<endl;
}
int main()
{
Student stu(0,"wei",15,88);
stu.Print();
cout<<stu.Getcount()<<endl;
stu.Insert(1,"xin",17,70);
stu.Print();
cout<<stu.Getcount()<<endl;
stu.Insert(1,"ken",22,89);
stu.Print();
cout<<stu.Getcount()<<endl;
stu.Delete(1);
stu.Print();
stu.get(1);
cout<<stu.Getcount()<<endl;
return 0;
{
Student stu(0,"wei",15,88);
stu.Print();
cout<<stu.Getcount()<<endl;
stu.Insert(1,"xin",17,70);
stu.Print();
cout<<stu.Getcount()<<endl;
stu.Insert(1,"ken",22,89);
stu.Print();
cout<<stu.Getcount()<<endl;
stu.Delete(1);
stu.Print();
stu.get(1);
cout<<stu.Getcount()<<endl;
return 0;
}