Esempio n. 1
0
int main()
{
    int k, i, p, q, dx, dy, dx1, dy1;
    static char fold[1 << ORDER];

    gr_on();  gr_window(0, 0, 640, 400, 1, 0);
    move(200, 140);
    dx = 0;  dy = 2;  draw_rel(3 * dx, 3 * dy);  p = 0;
    for (k = 1; k <= ORDER; k++) {
        fold[p] = LEFT;  q = 2 * p;
        for (i = p; i <= q; i++) {
            switch (fold[q - i]) {
            case RIGHT:
                fold[i] = LEFT;  dx1 = -dy;  dy1 = dx;
                break;
            case LEFT:
                fold[i] = RIGHT;  dx1 = dy;  dy1 = -dx;
                break;
            }
            draw_rel(dx + dx1, dy + dy1);
            draw_rel(3 * dx1, 3 * dy1);
            dx = dx1;  dy = dy1;
        }
        p = q + 1;
    }
    hitanykey();
    return EXIT_SUCCESS;
}
Esempio n. 2
0
File: koch.c Progetto: MiCHiLU/algo
int main()
{
    gr_on();  gr_window(0, 0, 2, 1, 1, 0);
    for (a = 0; a < 6; a++) {
        costbl[a] = cos(a * PI / 3);
        sintbl[a] = sin(a * PI / 3);
    }
    move(0, 0);  d = 2;  a = 0;  koch();
    hitanykey();
    return EXIT_SUCCESS;
}
Esempio n. 3
0
int main()
{
    int i;

    gr_on();
    for (i = 0; i < 100; i++)
        gr_ellipse(rand() % XMAX, rand() % YMAX,
                   rand() % 100, rand() % 100,
                   rand() % WHITE + 1);
    hitanykey();
    return EXIT_SUCCESS;
}
Esempio n. 4
0
int main()
{
    int i, order;

    printf("位数 = ");  scanf("%d", &order);
    gr_on();  gr_window(0, 0, 1, 1, 1, 0);
    h = 1;
    for (i = 2; i <= order; i++) h = h / (2 + h);
    move(0, 0);  rul(order);
    hitanykey();
    return EXIT_SUCCESS;
}
Esempio n. 5
0
void
put_helpscreen(int keyc, menukey_t *keyv)
{
    int k;
    int l;
    int winline;
    WINDOW *helpscreen;

    winline = LINES - (keyc + 5);
    if(winline < 0)
        winline = 0;

    helpscreen = newwin(keyc + 4, 29, winline, COLS - 30);
    keypad(helpscreen, TRUE);
    wattron(helpscreen, A_REVERSE);
    wmove(helpscreen, 0, 0);
    waddstr(helpscreen, " --------------------------- ");
    wmove(helpscreen, 1, 0);
    waddstr(helpscreen, "| Menu Help                 |");
    wmove(helpscreen, 2, 0);
    waddstr(helpscreen, "|                           |");
    l = 3;
    for(k = 0; k < keyc + 1; k++) {
        if(keyv[k].text == NULL)
            continue;
        wmove(helpscreen, l, 0);
        waddstr(helpscreen, keyv[k].text);
        l++;
    }
    wmove(helpscreen, l, 0);
    waddstr(helpscreen, " --------------------------- ");
    wrefresh(helpscreen);
    wattroff(helpscreen, A_REVERSE);
    hitanykey();
    wclear(helpscreen);
    wrefresh(helpscreen);
    delwin(helpscreen);
}