1
我不斷收到「未定義的引用'x'」,其中x是函數原型。我有功能映射出來,但主要仍然需要工作只是fyi。我只是想解決在按下之前ld返回錯誤1,但我似乎無法指出問題。ld返回1錯誤退出狀態C++
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
//Symbolic Constants
const int MAX=11;
//Function Prototypes
int buildQuizArray(int);
void printArray(string,int,int);
double calcQuizAverage(int,int);
void sortArray(int,int);
int main()
{
int quizScores[MAX];
int compQuiz;
int tempArray[MAX];
int average;
compQuiz = buildQuizArray(quizScores[MAX]);
quizScores[MAX]=tempArray[MAX];
average = calcQuizAverage(quizScores[MAX], compQuiz);
cout<<endl<<"Your quiz average is "<<average<<endl;
printArray ("Quiz Scores", tempArray[MAX], compQuiz);
sortArray(tempArray[MAX], compQuiz);
}
int buildQuizArray(int quizArray[])
{
int numQuiz, input, a;
a=0;
numQuiz=1;
cout << "Enter your score for quiz "<<numQuiz<<" (-1 to quit): ";
cin >> input;
while (input != -1)
{
quizArray[a] = input;
a++;
numQuiz++;
cout<< "Enter your score for quiz "<<numQuiz<<" (-1 to quit): ";
cin >> input;
}
return a+1;
}
void printArray(string reportTitle, int quizArray[], int numberOfQuizzes)
{
int a;
cout<< reportTitle <<endl<<"-----------"<<endl;
for (a=0; a<numberOfQuizzes; a++)
{
cout<< "Quiz " << a <<": " << setw(2) <<quizArray[a] <<"/10"<<endl;
}
}
double calcQuizAverage(int quizArray[], int numberOfQuizzes)
{
int sum, lowSum, avg, a;
a = 0;
sum = 0;
lowSum = quizArray[0] + quizArray[1];
for (a=0; a< numberOfQuizzes; a++)
{
sum += quizArray[a];
}
if (numberOfQuizzes <= 2)
{
avg = sum/(10 * numberOfQuizzes) * 100;
}
else
{
(sum - lowSum)/(10 * (numberOfQuizzes - 2)) * 100;
}
return avg;
}
void sortArray(int quizArray[], int numberOfQuizzes)
{
int min, a, b, temp;
for (a=0; a<numberOfQuizzes; a++)
{
min = a;
}
for(b=a+1; b<numberOfQuizzes; a++)
{
if (quizArray[a] < quizArray[min])
{
min = b;
}
}
temp = quizArray[a];
quizArray[a]=quizArray[min];
quizArray[min]=temp;
}
哇。非常感謝!剛開始,仍然在學習。再次感謝。 – Ekko 2014-11-06 05:52:52