如果可以
請加入我的MSN吧!
nice0908@hotmail.com
因為題目太長
所以放不上來@@
感恩
即時通 tim0908
謝了!
2007-12-01 14:54:04 · 1 個解答 · 發問者 Tim Yeh 1 in 電腦與網際網路 ➔ 程式設計
#include
#include
#include
#include
#define randomize() srand((unsigned)time(NULL))
#define MAX 50
void menu(void){
printf("====================== Array Operation Menu ======================\n");
printf("1. Fill the array with random numbers in the range of 0 to 1000.\n");
printf("2. Print the array.\n");
printf("3. Find the maximum and minimum value of the array.\n");
printf("4. Calculate the mean deviation of the numbers in the array.\n");
printf("5. Count the value distributions for each consecutive 100 numbers.\n");
printf("6. Exit.\n");
printf("==================================================================\n=>");
}
void no1(int Length, int *Number){
int l=Length,*n=Number,i;
randomize();
for(i=0;i
}
void no2(int Length, int *Number){
int l=Length,*n=Number,i;
for(i=0;i
}
void no3(int Length, int *Number){
int l=Length,*n=Number,i,j,tmp;
for(i=0;i
tmp=n[i],n[i]=n[j],n[j]=tmp;
}
double no4(int Length, int *Number){
int l=Length,*n=Number,i;
double mean=0,md=0;
for(i=0;i
mean/=l;
for(i=0;i
md/=l;
return md;
}
int main(int argc, char* argv[]){
//=====START=====//
int opt,n[MAX];
do{
do{
menu(),scanf("%d",&opt);
}while(!((opt>0)&&(opt<7)));
no1(MAX,n);
switch(opt){
case 1:
printf("50 random numbers in the range of 0 to 1000 has been filled into the array.\n");
break;
case 2:
no2(MAX,n);
break;
case 3:
no3(MAX,n);
printf("Min= %d, Max= %d\n",n[0],n[MAX-1]);
break;
case 4:
printf("mean deviation= %lf\n",no4(MAX,n));
break;
case 6:
printf("Bye!\n");
break;
}
}while(!(opt==6));
//=====END=====//
system("PAUSE");
return 0;
}
2007-12-02 06:50:09 · answer #1 · answered by Big_John-tw 7 · 0⤊ 0⤋