程序代码如下,要求填写空白代码。
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
struct StudentInfo {
int stdnumber;
double grade;
};
int main() {
const int arraySize = 30;
StudentInfo stdInfo[arraySize];
StudentInfo* pInfo[arraySize];
srand((unsigned)time(0));
for (int i=0; i<arraySize; ++i) {
pInfo[i] = &stdInfo[i];
}
for (int i=0; i<arraySize; ++i) {
pInfo[i]->grade = rand()%5 + ((double)rand()/(2*RAND_MAX));
pInfo[i]->stdnumber = rand();
}
cout << "Before Sorting: " << endl;
cout << "StudnetNumber" << "\t" << "Grade" << endl;
for (int i=0; i<arraySize; ++i) {
cout << pInfo[i]->stdnumber << "\t\t" << pInfo[i]->grade << endl;
}
????? //此处填代码,不止一行...
cout << "After Sorting: " << endl;
cout << "StudnetNumber" << "\t" << "Grade" << endl;
for (int i=0; i<arraySize; ++i) {
cout << pInfo[i]->stdnumber << "\t\t" << pInfo[i]->grade << endl;
}
return 0;
}
输出如下:
有错呀 大哥你能运行一下吗?需填空白处的第二行 那不应该是i吧
for(int m =arraySize-1; m>i;m-- {
嘻嘻,抢回答抢的太急,后面更新过了~
//此处填代码,不止一行... for(int k=0; k < arraySize; k++) {C++:悬赏高,Bubble Sort及指针问题。急在线等啊等。
} cout << "Before Sorting: " << endl; cout << "StudnetNumber" << "\\t" << "Grade" << endl;
c++用四个sorting来排列数组怎么做?在线等,急
void bubbleSort(int[], int);void insertSort(int[], int);void selectSort(int[], int);void mergeSort(int[], int, int, int[]);int main(){ int number = 0;cout << "enter the number of elements in tht array: ";cin >> number;int arr[100];int functionSelect = 0;cou...
JAVA问题简单的很,菜鸟送分,在线等
int intArray[];声明了一个整型数组,数组中的每个元素为整型数据。与C、C++不同,Java在数组的定义中并不为数组元素分配内存,因此[]中不用指出数组中元素个数,即数组长度,而且对于如上定义的一个数组是不能访问它的任何元素的。我们必须为它分配内存空间,这时要用到运算符new,其格式如下:array...