程序比较简单,高手帮忙看一下,编译通过没问题,连接时出错,可能自己不够仔细,是个愚蠢的问题也说不一定~~
现给出连接出错的信息:
StudentGrades.obj : error LNK2001: unresolved external symbol "double __cdecl average(int * const,int)" (?average@@YANQAHH@Z)
Debug/StudentGrades.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
看不懂~~~~~~~~~~~~~~~~~~
代码如下:
#include<iostream>
#include<iomanip>
using namespace std;
const int students=3;
const int grades=4;
int maximum(int arry[][grades],int rowSize,int colSize);//求最大成绩
int minimum(int arry[][grades],int rowSize,int colSize);//求最小成绩
double average(int arry[],int size);//////////////////////求平均值
void Print(int arry[][grades],int rowSize,int colSize);///打印输出
int main()
{
int stdGrades[students][grades]={{77,88,99,76},
{87,67,70,60},
{98,87,79,61}};
cout<<"学生成绩表为:\n";
Print(stdGrades,students,grades);
cout<<"最低的成绩为: "
<<minimum(stdGrades,students,grades)
<<"最高的成绩为: "
<<maximum(stdGrades,students,grades);
for(int i=1;i<=students;i++)
{
cout<<"第"<<i<<"个学生的平均成绩为: "
<<setiosflags(ios::fixed|ios::showpoint)
<<setprecision(2)
<<average(stdGrades[i-1],grades)
<<endl;
}
return 0;
}
int maximum(int arry[][grades],int rowSize,int colSize)
{
int max=0;
for(int i=0;i<rowSize;i++)
{
for(int j=0;j<colSize;j++)
{
if(arry[i][j]>max)
max=arry[i][j];
}
}
return max;
}
int minimum(int arry[][grades],int rowSize,int colSize)
{
int min=100;
for(int i=0;i<rowSize;i++)
{
for(int j=0;j<colSize;j++)
{
if(arry[i][j]<min)
min=arry[i][j];
}
}
return min;
}
double arverage(int arry[],int size)
{
//int avg;
int sum=0;
for(int i=0;i<size;i++)
{
sum+=arry[i];
}
//avg=static_cast<double>(sum)/size;
return static_cast<double>(sum)/size;
}
void Print(int arry[][grades],int rowSize,int colSize)
{
cout<<" [1] [2] [3]";
for(int i=0;i<rowSize;i++)
{
cout<<"\nstdGrades["<<i<<"]";
for(int j=0;j<colSize;j++)
{
cout<<setiosflags(ios::left)<<setw(5)
<<arry[i][j];
}
}
}