示例#1
0
文件: main.c 项目: faithche/tasks
int main(){
struct Square pobeda;
fillSquare(&pobeda);
printf("%f , %f , %f , %f" , pobeda.length12,pobeda.length23,pobeda.length34,pobeda.length41);
getchar();


return 0;
}
示例#2
0
int main()
{
    char *temp_arr = (char *)malloc(50 * sizeof(char));
    int r, c, rd, cd;
    int dim = getDim(temp_arr);
    char **square = make2D(dim);
    char **answer = make2D(dim);
    moveTemp(square, temp_arr, dim);
    fillSquare(square, dim);
    /*printSquare(square, dim);*/

    temp_arr = (char*)malloc(50 * sizeof(char));
    while((fgets(temp_arr, 50, stdin)) != NULL )
    {
        if(strlen(temp_arr) > 1)
        {
            temp_arr[strlen(temp_arr) - 1] = '\0';
            /*printf("searching for %s\n",temp_arr);*/

            for(r = 0; r < dim; r++)
                for(c = 0; c < dim; c++)
                    for(rd = -1; rd <= 1; rd++)
                        for(cd = -1; cd <= 1; cd++)
                        {
                            if(find(r, c, rd, cd, dim, square, temp_arr))
                            {
                                add(r, c, rd, cd, dim, square, answer, temp_arr);
                                cd = 2;
                                rd = 2;
                                c = dim + 1;
                                r = dim + 1;
                            }
                        }
        }
    }
    free(temp_arr);
    
    printSquare(answer, dim);

    free2D(square, dim);
    free2D(answer, dim);
    return 0;
}
示例#3
0
// fill buff
int SoundGenPCJr::chanGen(int chan, int16 *stream, int len) {
    ToneChan *tpcm;
    Tone toneNew;
    int fillSize;
    int retVal;

    tpcm = &_tchannel[chan];

    retVal = -1;

    while (len > 0) {
        if (tpcm->noteCount <= 0) {
            // get new tone data
            toneNew.freqCount = 0;
            toneNew.atten = 0xF;
            toneNew.type = kGenTone;
            if ((tpcm->avail) && (getNextNote(chan, &toneNew) == 0)) {
                tpcm->atten = toneNew.atten;
                tpcm->freqCount = toneNew.freqCount;
                tpcm->genType = toneNew.type;

                // setup counters 'n stuff
                // SAMPLE_RATE samples per sec.. tone changes 60 times per sec
                tpcm->noteCount = SAMPLE_RATE / 60;
                retVal = 0;
            } else {
                // if it doesn't return an
                tpcm->genType = kGenSilence;
                tpcm->noteCount = len;
                tpcm->avail = 0;
            }
        }

        // write nothing
        if ((tpcm->freqCount == 0) || (tpcm->atten == 0xf)) {
            tpcm->genType = kGenSilence;
        }

        // find which is smaller.. the buffer or the
        fillSize = (tpcm->noteCount <= len) ? tpcm->noteCount : len;

        switch (tpcm->genType) {
        case kGenTone:
            fillSize = fillSquare(tpcm, stream, fillSize);
            break;
        case kGenPeriod:
        case kGenWhite:
            fillSize = fillNoise(tpcm, stream, fillSize);
            break;
        case kGenSilence:
        default:
            // fill with whitespace
            memset(stream, 0, fillSize * sizeof(int16));
            break;
        }

        tpcm->noteCount -= fillSize;
        stream += fillSize;
        len -= fillSize;
    }

    return retVal;
}