标题:想给女朋友做一个,哪个大神有代码,麻烦发一下,感激不尽
只看楼主
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:432
帖 子:10064
专家分:41463
注 册:2014-5-20
得分:0 
学着写个玩玩
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>

HANDLE hOut;
unsigned int cc[32]= {0};
unsigned int ch[32]=
{
    0x00080000,0x00180400,0x00381C00,0x00180C00,
    0x18180C00,0x3FFFFFFE,0x00180C00,0x00180C00,
    0x00180C00,0x00180C00,0x20000008,0x7FFFFFF8,
    0x7000000C,0x1000000C,0x0900000E,0x03800006,
    0x07FFFFE0,0x0001C000,0x0001C000,0x0001C000,
    0x0081C000,0x01C1C000,0x03FFFFC0,0x0001C000,
    0x0011C000,0x0061C000,0x01C1C000,0x01C1C000,
    0x1181C000,0x3901C000,0x7FFFFFFE,0x00000004
};

int _BitTest(unsigned int *a, int n, int bit)
{
    return (a[n]>>bit)&1;
}

void _BitSet(unsigned int *a, int n, int bit)
{
    a[n] |= 1<<bit;
}

SHORT _rand(SHORT N)
{
    return (SHORT)((double)rand()/(RAND_MAX+1.0)*N);
}

void _saych(SHORT x, SHORT y, char c)
{
    COORD pos = {x, y};
    SetConsoleCursorPosition(hOut, pos);
    putchar(c);
}

void _say(SHORT i, SHORT j)
{
    if (_BitTest(ch,i,j))
    {
        if (!_BitTest(cc,i,j))
            _saych(j*2, i, _rand(27)+64);
    }
    else
        _saych(j*2, i, ' ');
    Sleep(1);
}

main()
{
    srand((unsigned)time(0));
    hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_CURSOR_INFO cursor_info = {1, 0};
    SetConsoleCursorInfo(hOut, &cursor_info);
    SHORT i, j, k;
    for (k=2000; k>0; --k)
    {
        i = _rand(32);
        j = _rand(32);
        _BitSet(cc, i, j);
        _saych(j*2, i, _rand(27)+64);
        Sleep(1);
    }
    for (k=2000; k>0; --k)
        _say(_rand(32), _rand(32));
    for (i=0; i<32; ++i)
        for (j=0; j<32; ++j)
          _say(i, j);
    getch();
    cursor_info.bVisible = 1;
    SetConsoleCursorInfo(hOut, &cursor_info);
}
2017-12-27 21:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-483651-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.124497 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved