2007-11-19, 07:33 PM
|
#2 (permalink)
|
註冊會員
|
語法:
#include<iostream>
using namespace std;
int main(){
int i,j,d[50],m=0,n=1000,x,a[10];
srand(time(NULL));
cout <<"The array is shown as follows:"<<endl;
for(i=0;i<10;i++) a[i]=0;
for(i=0;i<50;i++){
if(i%10==0) cout <<endl;
x=0;
while(x==0){
x=1;
d[i]=rand()%1001;
for(j=0;j<i;j++)
if(d[i]==d[j]) x=0;
}
if(n>d[i])n=d[i];
if(m<d[i])m=d[i];
if(d[i]<1000)a[d[i]/100]++;
else a[9]++;
cout <<d[i]<<" ";
}
cout <<endl<<endl<<"the maximum is : "<<m<<" ,and the minimum is : "<<n<<endl;
x=m=0;
for(i=0;i<50;i++)
x+=d[i];
x/=50;
for(i=0;i<50;i++)
m+=abs(d[i]-x);
cout <<endl<<"the mean deviation is : "<<(m/50)<<endl<<endl;
cout <<"The value distributes are shown as follows:"<<endl<<"Range Count"<<endl<<endl;
for(i=0;i<10;i++){
if(i!=0&&i!=9) cout<<i<<"00-"<<i<<"99 ";
else{
if(i==0) cout <<"0-99 ";
else cout <<"900-1000 ";
}
cout <<a[i]<<endl;
}
system("pause");
return 0;
}
若有錯我只能說下次請給詳細的測試輸出資料好嗎??
看不懂你題目所規定的輸出,只好階段性輸出那5項要求
|
|
|
送花文章: 15,
收花文章: 18 篇, 收花: 28 次
|