#include <stdio.h>
void main()
{
int arrsize;
int randset;
int max;
int min;
int arr[arrsize];
int i, j;
int swap;
float mean;
printf("Input array size:\n");
scanf("%d", &arrsize);
printf("Input random set:\n");
scanf("%d", &randset);
printf("Input maximum possible value:\n");
scanf("%d", &max);
printf("Input minimum possible value:\n");
scanf("%d", &min);
// SORTING //
for (i = arrsize; i > 0; i--)
for(j = 1 ; j < i ; j++)
// Subscripted value is neither array nor pointer vector //
**if(arrsize[j-1] > arrsize[j])**
{
swap = arr[j];
arr[j] = arr[j-1];
arr[j-1] = swap;
}
for (i=0; i < arrsize; i++)
printf("%d", arr[i]);
printf("\n\n");
// MEAN //
for(i = 0 ; i < arrsize ; i ++)
{
//Subscripted value is neither array nor pointer vector //
**mean += arrsize[i];**
mean/= arrsize;
printf("The mean is %.2lf\n\n", mean);
}
// MEDIAN //
if(arrsize%2 == 0)
{
printf("The median is %.2lf", (float)(arr[arrsize/2 -1] + arr[arrsize/2]);
}
else
{
printf("The median is %d", arr [arrsize/2]);
printf("\n\n\n");
}
printf("The midrange is %.2lf\n\n", (float)(arr[0] + arr[arrsize - 1] / 2);
}
void fillintarray(int myarray [], int arrsize, int min, int max, unsigned int randset)
{
int iter;
srand (randset);
for (iter =0 ; iter < arrsize ; iter++)
{
myarray[iter] = rand() % (max - min + 1) + min;
}
}
你好呀!我将有错误的行以粗体显示,错误是“下标值既不是数组也不是指针向量”这是我的 ComSci 类的练习 :) 非常感谢帮助!谢谢!:)