首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

帮帮忙吧~该怎么解决

2012-03-12 
帮帮忙吧~~~~~~~~~~!Commonboxstudent//定义全局变量intMenu(){cout [主选单:]

帮帮忙吧~~~~~~~~~~!


Commonbox   student;   //定义全局变量

int   Menu(){
cout   < < "===========[主选单:]=========== " < <endl;
int   n=1,select=-1;
cout   < <n++ < < ".输入学生成绩; " < <endl < <endl;
cout   < <n++ < < ".按学号排序; " < <endl < <endl;
cout   < <n++ < < ".按学号查找记录; " < <endl < <endl;
cout   < <n++ < < ".删除由学号指定的记录; " < <endl < <endl;
cout   < <n++ < < ".列出所有记录; " < <endl < <endl;
cout   < <n++ < < ".计算平均成绩; " < <endl < <endl;
cout   < < "0.退出; " < <endl < <endl;

cout   < < "[请选择(输入相应数字)]: ";
cin   > > select;
return   select;
}

char   Exit(){//返回一个字符患,用于确认退出
char   s;
cout < < "确定要退出程序吗?[Y/N]: ";
cin   > > s;
return   s;
}

void   Input(int   *num,   string   *name,   double   *mark){//输入学生信息

cout   < < "请输入   \n学号           : ";
cin     > > *num;
if(*num==-1)return;
else{
cout < < "名字:           ";
cin> > *name;
cout < < "数学           : ";
          cin> > mark[0];
  cout < < "英语           : ";
  cin> > mark[1];
  cout < < "C++             : ";
  cin> > mark[2];

return;
}

void   AddNew(){//增加记录

int   num=0;
doublemark[3];
string   name= " ";

cout < <endl < < "当输入的学号为-1时表示结束输入. " < <endl;
Input(&num,   &name,   mark);
while(num!=-1){
student.AddItem(num,name,mark);
Input(&num,   &name,   mark);
}
return;
}

void   DoFind(){//按学号查找

int   num;
cout < <endl < < "当输入的学号为-1时表示结束输入. " < <endl;
do{
cout   < < "请输入要查找的学生的学号:   ";
cin> > num;
if(num==-1)continue;
student.Search(num);
}while(num!=-1);

return;
}


void   DoDelete(){//删除记录

cout < <endl < < "当输入的学号为-1时表示结束输入. " < <endl;
int   num;
do{
cout   < < "请输入要删除的学生的学号: ";
cin> > num;
if(num==-1)continue;
student.RemoveItem(num);
}while(num!=-1);
return;
}
void   ShowAverage(){//输出平均数

double   avr_maths=student.mathsAverage();
double   avr_english=student.englishAverage();
double   avr_c=student.cAverage();

cout < < "共有记录:\t " < <student.ListCount() < <endl < <endl;
cout < < "数学平均成绩:\t " < <avr_maths < <endl < <endl;
cout < < "英语平均成绩: " < <avr_english < <endl < <endl;
cout < < "C++平均成绩: " < <avr_c < <endl < <endl;


return;
}
//-------****** <主函数开始> ******-------

int   main()
{

cout < < "Welcome!\n学生成绩管理系统\nVer   1.01\nBy   FondBoy\n\n ";



int   select;
char   s;

while(1)
{
                select=Menu();
switch(select)
{
                        case   0://退出程序
                s=Exit();
                if(s== 'y '   ||   s== 'Y ')return   0;
                break;

                        case   1://输入学生成绩
                        AddNew();
                break;
                                        case   2://按学号排序
                        student.Sort();
                break;


                        case   3://按学号查找记录
                                DoFind();
                break;

                        case   4:   //删除由学号指定的记录
                                DoDelete();
                    break;

                        case   5:   //列出所有记录
                                student.List();
                break;

                                case   6:   //输出平均成绩
                                        ShowAverage();
                  break;

                        default:
                  cout < < "无效输入! " < <endl;
}
}

              return   0;
}
有6   个错,实在不知道该怎么班,请帮帮忙吧~~~!
--------------------Configuration:   张文   -   Win32   Debug--------------------
Compiling...
为.cpp
G:\C++\张文\为.cpp(330)   :   error   C2601:   'AddNew '   :   local   function   definitions   are   illegal
G:\C++\张文\为.cpp(345)   :   error   C2601:   'DoFind '   :   local   function   definitions   are   illegal
G:\C++\张文\为.cpp(360)   :   error   C2601:   'DoDelete '   :   local   function   definitions   are   illegal
G:\C++\张文\为.cpp(372)   :   error   C2601:   'ShowAverage '   :   local   function   definitions   are   illegal


G:\C++\张文\为.cpp(389)   :   error   C2601:   'main '   :   local   function   definitions   are   illegal
G:\C++\张文\为.cpp(437)   :   fatal   error   C1075:   end   of   file   found   before   the   left   brace   '{ '   at   'G:\C++\张文\为.cpp(389) '   was   matched
Error   executing   cl.exe.

为.obj   -   6   error(s),   0   warning(s)


[解决办法]
void Input(int *num, string *name, double *mark){//输入学生信息

cout < < "请输入 \n学号 : ";
cin > > *num;
if(*num==-1)return;
else{
cout < < "名字: ";
cin> > *name;
cout < < "数学 : ";
cin> > mark[0];
cout < < "英语 : ";
cin> > mark[1];
cout < < "C++ : ";
cin> > mark[2];

return;
} //这里才没有匹配{}

热点排行