Ejemplo n.º 1
0
static void dofile(FILE * inf, char name[])
{
    unsigned char seq[7];
    uint32_t cdpt;
    size_t n = 0;
    size_t l = 0;
    int len;

    memset(seq, '\0', sizeof(seq) * sizeof(seq[0]));

    while (next_sequence(inf, seq) != -1) {
        n += seqlen(seq[0]);
        sequence_to_ucs4(seq, &cdpt);
        if ('\n' == cdpt)
            l++;
        cdpt = rot(cdpt);
        len = utf8encode(cdpt, (uint8_t *) seq);
        fwrite(seq, 1, len, stdout);
    }

    if (!valid_sequence(seq) && !feof(inf))
        fprintf(stderr,
                "rot32768: invalid UTF-8 sequence at line %llu (byte %llu) in %s\n",
                (unsigned long long int) l, (unsigned long long int) n,
                name);
}
 read_t * next_read() {
   while(true) {
     if(sequence) {
       if(current_read < sequence->nb_reads)
         return &sequence->reads[current_read++];
       sequence->file->dec();
       wq->enqueue(sequence);
       sequence = 0;
     }
     current_read = 0;
     while(!sequence)
       if(!next_sequence())
         return 0;
   }
 }
Ejemplo n.º 3
0
int main (void) {
    char seqnc [10] = {9, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    char typ_out [23] = "0/00 + 0/00 + 0/00 = 1";
    int cnt, plc, rund = 0, rmn = 0;

    printf ("       *******************************************\n");
    printf ("       *    ?      ?      ?                      *\n");
    printf ("       *  ---- + ---- + ---- = 1                 *\n");
    printf ("       *   ??     ??     ??                      *\n");
    printf ("       *    Find out the number behind           *\n");
    printf ("       *       every question mark. They         *\n");
    printf ("       *         are 1 to 9, and all different!  *\n");
    printf ("       *******************************************\n");

    do {
      if (chk_eqn (seqnc)) {
	for (cnt = 3; cnt > 0; cnt--) {
	    plc = (cnt - 1) * 7;
	    typ_out [plc] = seqnc [cnt + 6] + '0';
	    typ_out [plc + 3] = seqnc [cnt * 2] + '0';
	    typ_out [plc + 2] = seqnc [cnt * 2 - 1] + '0';
	}
	printf ("\r%s  \n", typ_out);
      }

      rmn++;
      rmn %= 100;
      if (rmn == 0) {
	rund++;
	printf ("\r%d00 combination tested.", rund);
      }

      next_sequence (seqnc);
    } while (jump (seqnc) == 0);

    printf ("\r%d%d combination tested.\n", rund, rmn);

    return 0;
}