#include
#include
#include
#include
using namespace std;
const int n=1;
class Stu_Information
{
char Stu_zxf[3];
char Stu_num[6];
char Stu_name[8];
char Stu_sex[2] ;
char Stu_zhuanye[10] ;
char Stu_birthday[8] ;
char Stu_BZ[20] ;
public:
void set_stu();
void display();
friend void find(Stu_Information stu,char *c );
};
void Stu_Information::set_stu()
{
cout<<"请输入学号:";
l: char *num=new char[6];
cin>>num;
if(strlen(num)!=6)
{
cout<<"请输入6位学号数`!\n";
cout<<"请再次输入学号:";
goto l;
}
strcpy(Stu_num, num);
cout< cout<<"请输入姓名:";
l1: char *name=new char[8];
cin>>name;
if(strlen(name)>8)
{
cout<<"你输入的名字过长~!\n";
cout<<"请再次输入姓名:";
goto l1;
}
strcpy(Stu_name,name);
cout<<"请输入性别:";
l2: char *sex=new char[2] ;
cin>>sex;
if(strcmp(sex,"男")!=0&&strcmp(sex,"女")!=0)
{
cout<<"请输入正确性别~!\n";
cout<<"请再次输入性别:";
goto l2;
}
strcpy(Stu_sex,sex);
cout<<"请输入专业名:";
l3: char *zhuanye=new char[10] ;
cin>>zhuanye;
if(strlen(zhuanye)>10)
{
cout<<"你输入的专业名过长~!\n";
cout<<"请再次输入专业名:";
goto l3;
}
strcpy(Stu_zhuanye,zhuanye);
cout<<"请输入出生日期‘19860506’:";
l4: char *birthday=new char[8] ;
cin>>birthday;
if(strlen(birthday)!=8)
{
cout<<"请仿照例子 再次输入出生日期: ";
goto l4;
}
strcpy(Stu_birthday,birthday);
cout<<"请输入总学分:";
l5: char *zxf=new char[3];
cin>>zxf;
if(strlen(zxf)<2||strlen(zxf)>3)
{
cout<<"总学分应在10~100之间~!\n";
cout<<"请再次输入总学分 :";
goto l5;
}
strcpy(Stu_zxf,zxf);
cout<<"备注: ";
l6: char *BZ=new char[20] ;
cin>>BZ;
if(strlen(BZ)>20)
{
cout<<"备注应在20个字内注释!\n";
cout<<"备注:\n";
goto l6;
}
strcpy(Stu_BZ,BZ);
ofstream xr("student_information.text");
xr<
}
void Stu_Information::display()
{
cout< cout<}
void find(Stu_Information stu,char *c )
{
if(strcmp(c,stu.Stu_num)==0)
{
cout< < <
}
else
cout<<"没有该生信息~!\n";
}
void main()
{
int i;
Stu_Information student[n];
for( i=0;i student[i].set_stu();
for( i=0;i student[i].display();
}
--------------------next---------------------
阅读(1086) | 评论(0) | 转发(0) |