More Related Content
More from Hui-Shih Leng (11)
[程式設計]標準差
- 1. [程式設計]輸入10個正整數,求這組數值的標準差。<br />#include<stdio.h><br />#include<math.h><br />void main(void){<br /> int i, a[10], sum=0;<br /> float avg=0.0;<br /> for (i=0; i<10; i++){<br /> scanf(quot;
%dquot;
, &a[i]);<br /> sum+=a[i];<br /> };<br /> avg=sum/10;<br /> sum=0;<br /> for (i=0; i<10; i++){<br /> sum+=(a[i]-avg)*(a[i]-avg);<br /> };<br /> printf(quot;
%fquot;
, sqrt(sum/10));<br />}<br />