Пример #1
0
int main(void)
{   srand(time(NULL));
    char prog;
    int seed, end=0;

        //Prompts the user to seed the program.
        printf("Enter seed value, either:\n\t>= 0 to randomize rand( ) with u");
        printf("ser-input seed value\n\t<  0 to randomize rand( ) with system");
        printf(" time\n");

        scanf("%i", &seed);

        if(seed>=0)
            srand(seed);

        if(seed<0)
            srand(time(NULL));

        do
        {   ct1=ct2=ct3=ct4=ct5=0;

            printf("Do you want to use the assigned function, play poker or end program(A/P/E)?");
            prog=getchar();
            prog=getchar();

            printf("\n");

            if (prog=='A' || prog=='a')
            {   for(ct1=0; ct1<52; ct1++)
                    createDeck();

                assigned();
            }

            else if(prog=='p' || prog=='P')
            {   poker();
            }
            else if(prog=='e' || prog=='E')
            {
                for(ct2=0; ct2<100000; ct2++)  //Smilies!
                    printf("%2c", 1);
                end++;
            }
            //Prints after invalid inputs.
            else
                printf("Would you like to try that again.....\n\n");

        }while(end==0);
        return 0;
}   // end main
Пример #2
0
static int read_data()
        {
        int i;
        int j;
        int prind;
        int runlen;
        unsigned int u;
        double a;

        n=0L; run_start=0L; up=-1;
        sum1=sum2=0.0;

        if (n_sub)
            {
            i_sub=0; sub_sum1=0.0; sub_min=1e30; sub_max=-1e30;
            for (i=0; i<n_subclass; ++i)
                {
                p_mean[i]=p_min[i]=p_max[i]=0;
                }
            }

        if (fr_n)
            for (i=0; i<fr_n; ++i) fr_f[i]=0L;

        lagpos=0;
        for (i=0; i<maxlag; ++i) lagv[i]=lagvv[i]=0.0;
        for (i=0; i<maxgap; ++i) gap[i]=0L;
        gaplen=gapmax=0L;
        if (permlen)
            {
            i_perm=0;
            for (u=0; u<n_perm; ++u) f_perm[u]=0L;
            }
        if (poklen)
            {
            i_pok=0;
            for (u=0; u<n_pok; ++u) f_pok[u]=0L;
            for (u=0; u<poklen; ++u) f1_pok[u]=0;
            }
        if (couplen)
            {
            init_coup();
            for (u=0; u<coup_max; ++u) f_coup[u]=0L;
            }
        i=spfind("PRIND"); if (i>=0) prind=atoi(spb[i]); else prind=0;
        sur_print("\n");
        for (j=d.l1; j<=d.l2; ++j)
            {
            if (unsuitable(&d,j)) continue;
/***********************
            if (sur_kbhit()) { sur_getch(); prind=1-prind; }
************************/
            if (prind)
                {
                sprintf(sbuf,"%d ",j); sur_print(sbuf);
                }

            data_load(&d,j,var,&x);
            if (x==MISSING8) continue;
            ++n;
            sum1+=x; sum2+=x*x;
            if (n_sub)
                {
                sub_sum1+=x;
                if (x<sub_min) sub_min=x;
                if (x>sub_max) sub_max=x;
                ++i_sub;
                if (i_sub==n_sub)
                    {
                    sub_sum1/=(double)n_sub;
                    a=muste_cdf_std(sqrt(12.0*(double)n_sub)*(sub_sum1-0.5));
                    i=a*(double)n_subclass;
                    ++p_mean[i];

                    i=pow(1.0-sub_min,(double)n_sub)*(double)n_subclass;
                    ++p_min[i];
                    i=pow(sub_max,(double)n_sub)*(double)n_subclass;
                    ++p_max[i];

                    i_sub=0; sub_sum1=0.0; sub_min=1e30; sub_max=-1e30;
                    }
                }
            if (fr_n) freq();
            runs_updown();
            lags();
            if (maxgap) gaps();
            if (permlen) permtest();
            if (poklen) poker();
            if (couplen) coupon();
            xlag=x;
            }
        runlen=n-run_start;
        if (runlen>MAXRUN) runlen=MAXRUN-1;
        if (up) ++runs_up[(int)(runlen-1)];
        else    ++runs_down[(int)(runlen-1)];
        if (maxgap)
            {
            if (gaplen>gapmax) gapmax=gaplen;
            if (gaplen>(unsigned int)(maxgap-1)) gaplen=maxgap-1;
            ++gap[(int)gaplen];
            }
        return(1);
        }