#include
#include
using namespace std;
void mean (const int [],int);
void median (int [],int);
void mode (int [],int [],int);
void bubbleSort (int [],int);
void printArray(const int[],int);
int main()
{
const int responseSize=99;
int frequency[10]={0};
int response[responseSize]=
{6,7,8,9,8,7,8,9,8,9,
6,7,8,9,3,9,8,7,8,7,
6,7,8,9,3,9,8,7,8,7,
7,8,9,8,9,8,9,7,8,9,
6,7,8,7,8,7,9,8,9,2,
7,8,9,8,9,8,9,7,5,3,
5,6,7,2,5,3,9,4,6,4,
7,8,9,6,8,7,8,9,7,8,
7,4,4,2,5,3,8,7,5,6,
4,5,6,1,6,5,7,8,7,};
mean(response,responseSize);
median(response,responseSize);
mode(frequency,response,responseSize);
return 0;
}
void mean(const int answer[],int arraySize)
{
int total=0;
cout<<"********/n mean/n********/n";
for(int i=0;i
cout<
void median(int answer[],int size)
{
cout<<"/n********/n Median/n********/n"
<<"未排序的数组是";
printArray(answer,size);
bubbleSort(answer,size);
cout<<"/n/n排序后的数组是:";
printArray(answer,size);
cout<<"/n/n在这"<
void mode(int freq[],int answer[],int size)
{
int largest=0;
int modeValue=0;
cout<<"/n********/n Mode/n********/n";
for(int i=1;i<10;i++)
freq[i]=0;
for(int j=0;j
cout<<"Response"< for(int rating=1;rating<10;rating++){ if(freq[rating]>largest){ for(int k=1;k<=freq[rating];k++) cout<<"数据处理直方图"< void bubbleSort(int a[],int size) for(int pass=1;pass void printArray(const int a[],int size)
cout<
largest=freq[rating];
modeValue=rating;}
cout<<"*";
cout<<"/n";
}
{
int hold;
hold=a[j];
a[j]=a[j+1];
a[j+1]=hold;
}
}
}
}
{
for(int i=0;i
cout<
}