////////////////////////////新增信息修改功能,未完善。
#include<iostream>
#include <string>
#include<conio.h>
void bangzhu();
using namespace std;
struct sj
{public :
int year,month,day; ////////时间类
void shuru()
{cin>>year>>month>>day;
}
};
class student ////////////学生类
{
public :
string xm,kc[5];
int bj,xh,cj[5];
sj time;
void sr() //////初始化输入学生信息
{cout<<"请输入学号";
cin>>xh;
system("cls");
cout<<"请输入姓名";
cin>>xm;
system("cls");
cout<<"请输入入学日期中间用空格隔开";
time.shuru();
system("cls") ;
cout<<"请输入班级";
cin>>bj;
system("cls");
cout<<"请输入课程(5门)中间用空格隔开";
for(int i=0;i<5;i++)
cin>>kc[i];
system("cls");}
void chengji() ///////成绩录入
{int i;
for(i=0;i<5;i++)
{cout<<"请输入"<<kc[i]<<"的成绩"<<endl;
cin>>cj[i];}
}
//student chazhaoxg(student t);
/* void shuruchengji()
{int i;
for(i=0;i<5;i++)
{
cout<<"请输入"<<kc[i]<<"的成绩";
cin>>cj[i];
}
}*/
};
string mima() ////////初始化设置密码
{cout<<"请设置密码:";
string mm1,mm2;
char ch;
while ((ch=_getch())!=13)
{
mm1+=ch;
cout<<"*";
}
cout<<endl;
cout<<"请再次确认密码:";
while ((ch=_getch())!=13)
{
mm2+=ch;
cout<<"*";
}
system("cls");
if(mm1==mm2)
return mm1;
else
mima();
}
int denglu(string mm) /////////登陆程序
{
cout<<"请输入登陆密码:";
string mm1;
char ch;
while ((ch=_getch())!=13)
{
mm1+=ch;
cout<<"*";
}
system("cls");
if(mm==mm1)
return 1;
else
{cout<<"密码错误,您还有两次机会,请重试";
while ((ch=_getch())!=13)
{
mm1+=ch;
cout<<"*";
}
system("cls");
if(mm==mm1)
return 1;
else
{cout<<"密码错误,您还有一次机会,请重试";
while ((ch=_getch())!=13)
{
mm1+=ch;
cout<<"*";
}
system("cls");
if(mm==mm1)
return 1;
else
{cout<<"密码错误,请明天再试";
return 0;}
}
}
}
student chazhaoxg(student t)
{cout<<"修改姓名请输入1,修改入学时间请输入2,修改班级请输入3."<<endl;
cout<<"修改课程请输入4,修改成绩请输入5";
int a,i;
cin>>a;
switch(a)
{case 1:cin>>t.xm;break;
case 2:cin>>t.time.year>>t.time.month>>t.time.day;break;
case 3:cin>>t.bj;break;
case 4:for(i=0;i<5;i++) cin>>t.kc[i];break;
case 5:for(i=0;i<5;i++) {cout<<t.xm;t.chengji();}break;
}
return t;
}
void shuchuxinxi(student t)
{
cout<<t.xh<<‘ ‘<<t.xm<<‘ ‘<<t.time.year<<t.time.month<<t.time.day<<t.bj<<‘ ‘;
}
int main() ////主函数..................................................................................
{int n,i,xh;
string mm;
student stu[500];
mm=mima();
i=denglu(mm);
if(i)
{ cout<<"请输入学生人数: ";
cin>>n;
system("cls");
for(i=0;i<n;i++)
stu[i].sr();
int a;
bangzhu();
while(cin>>a)
{if(a==0)
break;
else
{
switch(a)
{case 1: (n++,stu[n].sr());break;
case 2: {for(i=0;i<n;i++)cout<<stu[i].xm;stu[i].chengji();}break;
case 3: cout<<"请输入学号 ";cin>>xh;for(i=0;i<n;i++) if(stu[i].xh==xh) stu[i]=chazhaoxg(stu[i]);break;
case 4: cout<<"请输入学号 ";cin>>xh;for(i=0;i<n;i++) if(stu[i].xh==xh) shuchuxinxi(stu[i]);break;
case 9:bangzhu();break;}}
}}
return 0;
}
void bangzhu() //操作指令提示
{ cout<<"请输入以下指令"<<endl<<endl;
cout<<" 1.添加学生 " <<endl;
cout<<"============================"<<endl;
cout<<" 2.成绩录入 "<<endl;
cout<<"============================"<<endl;
cout<<" 3.输入学号修改学生信息 "<<endl;
cout<<"============================"<<endl;
cout<<" 4,"<<endl;
cout<<"============================"<<endl;
cout<<" 5,"<<endl;
cout<<"============================"<<endl;
cout<<" 9."<<endl;
cout<<"============================"<<endl;
cout<<" 0.结束本程序 "<<endl ;
cout<<"============================"<<endl;
}
java 布局之FlowLayout