作者thorstan1234 (似有似無的簽名檔~)
看板NTUFM-91
標題[討論] test~
時間Tue Apr 27 11:30:50 2004
from 純淵個版~
#include <stdio.h>
#include <conio.h>
#include <math.h>
int n,a=0;
float Z,A,B,D,TD,AD,SD,TD2=0;
main()
{
while(1)
{
printf("please enter d:");
scanf("%f",&D);
if (D==0) break;
n++;
TD=TD+D;
TD2=TD2+pow(D,2);
}
printf("please enter alpha:\n1:alpha=0.1\n2:alpha=0.01\n3:alpha=0.05\n");
scanf("%d",&a);
switch(a)
{
case 1:
Z=1.645; break;
case 2:
Z=2.575; break;
case 3:
Z=1.96; break;
}
AD=TD/n;
SD=sqrt((n*TD2-pow(TD,2))/n/(n-1));
SD=sqrt((n*TD2-pow(TD,2))/n/(n-1));
A=AD+Z*SD/sqrt(n);
B=AD-Z*SD/sqrt(n);
printf("Z=%f\n",Z);
printf("AD=%f,TD=%f,SD=%f\n",AD,TD,SD);
printf("Answer from %f to %f \n",A,B);
}
ps:因為case裡面不能容納浮點述的存在所以用1,2,3(整數)來代替alpha值
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.244.186
→ smallyuan:或用強者百倍法!!! d^^b 推 140.112.183.98 04/27
→ thorstan1234:那是啥~ -.-" 推140.112.244.186 04/27
→ sunset:我也不懂耶 @@ 推140.112.225.197 04/27