第一题结果:#include <stdio.h>#define DATALEN 27int data[DATALEN]=\x09{13, 15, 16, \x09 16, 19, 20, \x09 20, 21, 22, \x09 22, 25, 25,\x09 25, 25, 30, 33, 33, 35, 35, 35, 35, \x09 36, 40, 45, \x09 46, 52, 70};int nSmoothByMeans[DATALEN]={0};int nSmoothByMedians[DATALEN]={0};int nSmoothByBoundaries[DATALEN]={0};void SmoothByMeans(int depth){\x09int i=0,j=0;\x09int sum=0 , mean=0;\x09for(i=0;i<27;i=i+3)\x09{\x09\x09for (j=i;j<i+depth;j++)\x09\x09{\x09\x09\x09sum+=data[j];\x09\x09}\x09\x09mean = sum/depth;\x09\x09for (j=i;j<i+depth;j++)\x09\x09{\x09\x09\x09nSmoothByMeans[j]=mean;\x09\x09}\x09\x09sum = 0;\x09}}void SmoothByMedians(int depth){\x09int i=0,j=0;\x09for(i=1;i<27;i=i+3)\x09{\x09\x09for (j=i-1;j<i+depth;j++)\x09\x09{\x09\x09\x09nSmoothByMedians[j]=data[i];\x09\x09}\x09}}void SmoothByBoundaries(int depth){\x09int i=0,j=0;\x09for(i=0;i<27;i++)\x09{\x09\x09nSmoothByBoundaries[i]=data[i];\x09}\x09for (i=1;i<27;i=i+3)\x09{\x09\x09if (data[i]-data[i-1]>data[i+1]-data[i])\x09\x09{\x09\x09\x09nSmoothByBoundaries[i]=data[i+1];\x09\x09}\x09\x09else\x09\x09{\x09\x09\x09nSmoothByBoundaries[i]=data[i-1];\x09\x09}\x09}}void main(){\x09int depth = 3;\x09int i=0;\x09int j=0;\x09SmoothByMeans(3);\x09SmoothByMedians(3);\x09SmoothByBoundaries(3); printf("原始数据:\n");\x09for(i=0,j=1;i<27;i=i+3,++j)\x09{\x09\x09\x09\x09printf("Bin %d : %d,%d,%d\n",\x09\x09\x09j,data[i],data[i+1],data[i+2]);\x09}\x09printf("使用平均值:\n");\x09for(i=0,j=1;i<27;i=i+3,++j)\x09{\x09\x09\x09\x09printf("Bin %d : %d,%d,%d\n",\x09\x09\x09j,nSmoothByMeans[i],nSmoothByMeans[i+1],nSmoothByMeans[i+2]);\x09}\x09printf("使用中值:\n");\x09for(i=0,j=1;i<27;i=i+3,++j)\x09{\x09\x09\x09\x09printf("Bin %d : %d,%d,%d\n",\x09\x09\x09j,nSmoothByMedians[i],nSmoothByMedians[i+1],nSmoothByMedians[i+2]);\x09}\x09printf("使用边界值:\n");\x09for(i=0,j=1;i<27;i=i+3,++j)\x09{\x09\x09\x09\x09printf("Bin %d : %d,%d,%d\n",\x09\x09\x09j,nSmoothByBoundaries[i],nSmoothByBoundaries[i+1],nSmoothByBoundaries[i+2]);\x09}}