这是我在大学里C++的一个功课,题目要求使用两个ARRAYS去输入最多20个学生的名字和分数,和用户可以选择以下个5个功能。功能的程式老师已经给了我们
程式如下
1. 1. int countSize(const float scores[], const stringnames[]);
2. 2. void getMax(float& max, const float scores[],const string names[], int actualSize);
3. 3. float firstMin(const float scores[], const stringnames[], int n);
4. 4. bool find(const float scores[], const string names[],int n, float target);
5. 5. void display(const float scores[], const stringnames[]);
这是我写的程式,可是他不断提示说出现错误0xcccccccc 求大神解答
#include <iostream>
#include <string>
using namespace std;
int countSize(const float scores[], const string names[]);
void getMax(float& max, const float scores[], const string names[], int actualSize);
float firstMin(const float scores[], const string names[], int n);
bool find(const float scores[], const string names[], int n, float target);
void display(const float scores[], const string names[]);
int main()
{
const int size = 20;
int number,n;
char choice;
string name[size];
float scores[size];
cout << "1: Count the number of students\n" << "2: Find the maximum and the minimum scores\n"
<< "3: Find the minimum for the first n elements \n" << "4: Find x from the first n elements\n"
<< "5: Print all the students with their scores\n";
cout << "++++++++++++++++++++++++++++++++++++++++++++++++\n";
cout << "Please enter the students name\n";
cin >> name[size];
cout << "Please enter the students scores\n";
cin >> scores[size];
do
{
cout << "Please enter your choice (1-5)\n";
cin >> number;
switch (number)
{
case 1:
int countSize(const float scores[], const string names[]);
break;
case 2:
void getMax(float& max, const float scores[], const string names[], int actualSize);
break;
case 3:
cout << "Please enter the value for n:\n";
cin >> n;
float firstMin(const float scores[], const string names[], int n);
cout << "The minimum for the first" << n << "elements is" << scores[] << "by" << name[];
break;
case 4:
bool find(const float scores[], const string names[], int n, float target);
break;
default:
void display(const float scores[], const string names[]);
break;
}
cout << "Do you wish to continue? (Y/N):";
cin >> choice;
} while (choice = "Y" || "y");
system("pause");
return 0;
}
程式如下
1. 1. int countSize(const float scores[], const stringnames[]);
2. 2. void getMax(float& max, const float scores[],const string names[], int actualSize);
3. 3. float firstMin(const float scores[], const stringnames[], int n);
4. 4. bool find(const float scores[], const string names[],int n, float target);
5. 5. void display(const float scores[], const stringnames[]);
这是我写的程式,可是他不断提示说出现错误0xcccccccc 求大神解答
#include <iostream>
#include <string>
using namespace std;
int countSize(const float scores[], const string names[]);
void getMax(float& max, const float scores[], const string names[], int actualSize);
float firstMin(const float scores[], const string names[], int n);
bool find(const float scores[], const string names[], int n, float target);
void display(const float scores[], const string names[]);
int main()
{
const int size = 20;
int number,n;
char choice;
string name[size];
float scores[size];
cout << "1: Count the number of students\n" << "2: Find the maximum and the minimum scores\n"
<< "3: Find the minimum for the first n elements \n" << "4: Find x from the first n elements\n"
<< "5: Print all the students with their scores\n";
cout << "++++++++++++++++++++++++++++++++++++++++++++++++\n";
cout << "Please enter the students name\n";
cin >> name[size];
cout << "Please enter the students scores\n";
cin >> scores[size];
do
{
cout << "Please enter your choice (1-5)\n";
cin >> number;
switch (number)
{
case 1:
int countSize(const float scores[], const string names[]);
break;
case 2:
void getMax(float& max, const float scores[], const string names[], int actualSize);
break;
case 3:
cout << "Please enter the value for n:\n";
cin >> n;
float firstMin(const float scores[], const string names[], int n);
cout << "The minimum for the first" << n << "elements is" << scores[] << "by" << name[];
break;
case 4:
bool find(const float scores[], const string names[], int n, float target);
break;
default:
void display(const float scores[], const string names[]);
break;
}
cout << "Do you wish to continue? (Y/N):";
cin >> choice;
} while (choice = "Y" || "y");
system("pause");
return 0;
}