#include #include #include double Wert(double a[],double b[], double c[]) { int i; double s; for (i=1;i<=3;i++) { s+=(a[i]+b[i])*c[i]; } return (1/s); } void main() { //FILE *stream; int n=1,j; double sm=0,sqm=0,stabw=0,prozabw=0,pa; double a[4]; double b[4]; double c[4]; double s[10000]; //char datei[50]; printf("ProzAbw: "); scanf("%lf",&pa); //printf("Ausgabedateiname: "); scanf("%s",datei);*/ do { a[1]=double(random())/RAND_MAX; a[2]=double(random())/RAND_MAX; a[3]=double(random())/RAND_MAX; b[1]=double(random())/RAND_MAX; b[2]=double(random())/RAND_MAX; b[3]=double(random())/RAND_MAX; c[1]=double(random())/RAND_MAX; c[2]=double(random())/RAND_MAX; c[3]=double(random())/RAND_MAX; s[n]=Wert(a,b,c); printf("%lf\n",s[n]); sm+=s[n]; if (n>1) { sqm=0; for (j=1;j<=n;j++) { sqm+=s[j]*s[j];} stabw=sqrt(((sqm/n)-((sm/n)*(sm/n)))/(n-1)); prozabw=stabw*(n/sm)*100; printf("Ergebnis: %1.5le +- %1.5le; Prozentuale Abw.: %lf bei n=%d\n",sm,stabw,prozabw,n);} else prozabw=100; n++; } while (prozabw > pa); }