c++ 看看那里错了 第二个名字不能输入

来源:百度知道 编辑:UC知道 时间:2024/05/31 09:44:20
#include <iostream>
#include <iomanip>

using namespace std;

//*********************************************
int studentave(int a[5][4], int j)//学生个人平均成绩,返回数值便于print函数调用
{
int sum=0;
for(int i = 0; i < 3; ++i)
{
sum += a[j][i];
}
return sum/3;
}

//*********************************************
void inputgrade(int a[5][4])//学号和成绩的成绩录入
{
int i = 0,j = 0;
for ( ; i <= 4; ++i )
{
cout << "enter the school number and the grade of student " << i+1 <<":" <<endl;
for( j =0; j <= 3; ++j)
{
if( j == 0 )
{
cout << "Input the school number: "; //输入学号
cin >> a[i][j];
}
else
{
cout << "Input the grade of lesson" << j << ": ";//输入成绩
cin >> a[i][j];

我运行了,正确的呀. 第二个名字完全可以输入.是不是你编译系统的原因啊.
delete [](name[i]); 将i去掉不行.就会出现"syntax error : ']'"的错误.
要么改成这样也行:delete []name;
其中delete的一般语法形式为:delete 指针变量和delete []指针变量两种形式.

// delete [](name[i]); 将i去掉试一下,还有你换成VC++6.0编译一下看看,你是在DEV-C++里面编译的吧

数组用以做形参