• linux 画图程序测试三


    该程序显示字符左右移动

    /**
    * curses3.c
    */
    #include
    <stdio.h>
    #include
    <curses.h>
    #include
    <sys/ioctl.h>
    #include
    <signal.h>
    void restandend();
    int main(int ac,char *av[])
    {
    struct winsize wbuf;
    int rows,cols;
    int dir=+3,pos=0;
    //signal(SIGINT,restandend);
    if(ioctl(0,TIOCGWINSZ,&wbuf)!=-1)
    {
            rows
    =wbuf.ws_row;
            cols
    =wbuf.ws_col;
    }
    rows
    =10;
    //printf("row=%d col=%d\n",rows,cols);
    initscr();
    while(1)
    {
            move(rows,pos);
            addstr(
    "cartoon");
            
    if(pos>(cols-9&& dir==+3)
                    dir
    =-3;
            
    if(pos<=0 && dir==-3)
                    dir
    =+3;
            sleep(
    1);
            refresh();
            move(rows,pos);
            addstr(
    "       ");
            pos
    +=dir;
    }
    standend();
    return 0;
    }
    void restandend()
    {
    move(
    0,0);
    addstr(
    "exit");
    refresh();
    standend();
    exit(
    1);
    }
  • 相关阅读:
    再见OI,AFO
    时间复杂度
    NOIP真题:矩阵取数问题
    [USACO12FEB]附近的牛Nearby Cows
    合唱队
    子串
    ZJOI2010基站选址
    分治FFT学习笔记
    「HAOI2018」染色
    「SDOI2015」序列统计
  • 原文地址:https://www.cnblogs.com/ringwang/p/1429906.html
Copyright © 2020-2023  润新知