主题:回车开始停止问题求助
tomliu05
[专家分:0] 发布于 2010-12-05 11:41:00
有一个抽奖问答,先输入每个人的编号
之后按回车屏幕上开始闪烁编号,要求位置不动,在同一位置闪动编号
最后再按一次回车停止,屏幕上显示中奖的编号
现在我想知道怎么才能用回车开始和停止
我用了循环,就无法停止。不用循环就无法不停显示数字。
求高手指教
回复列表 (共3个回复)
沙发
bruceteen [专家分:42660] 发布于 2010-12-05 12:57:00
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
int main()
{
// 得到当前光标位置
HANDLE hOutput = ::GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO info;
::GetConsoleScreenBufferInfo( hOutput, &info );
for(;;)
{
// 设置光标显示的位置,并清除掉此行的字符
::SetConsoleCursorPosition( hOutput, info.dwCursorPosition );
printf( "%*s", info.dwSize.X-info.dwCursorPosition.X, "" );
::SetConsoleCursorPosition( hOutput, info.dwCursorPosition );
// 显示一个随机值作为演示
printf( "%d", rand() );
// 检测用户是否输入回车
for( clock_t t=clock(); clock()-t<=CLOCKS_PER_SEC/2; Sleep(1) ) // 设定为0.5秒,以免显示得太快,眼花缭乱
{
if( _kbhit() )
{
int c = _getch();
if( c==0x00 || c==0xE0 ) // 当遇到 功能键或方向键时,需要读取两次
_getch();
else if( c == '\r' )
return 0;
}
}
}
return 0;
}
板凳
cfj469933485 [专家分:950] 发布于 2010-12-05 16:45:00
bruceteen大哥,你好
我是C菜鸟,你应该用到API的知识。我也想学,但是真不知道如何下手
不知道看什么书,不知道能否给点意见。
3 楼
vrgdfdsg [专家分:0] 发布于 2010-12-10 11:09:00
Start [url=http://www.mmopowerlevel.net]wow power leveling[/url] as Skinner and a Herbalist or Miner for a while to gather resources. You may have to travel
to a main town to learn these skills early - but its worth doing early. Skinner [url=http://www.mmopowerlevel.net]buy wow power leveling[/url] as you will be
killing many skinable mobs [url=http://www.mogxe.com/PowerLevel.php?gid=1]wow power leveling[/url] early on, and either Herbalist or Miner as the
[url=http://www.mogxe.com/PowerLevel.php?gid=21]aion power leveling[/url] radar marker conflicts - you cant have both a Herbalist and Miner radar blip on. I
[url=http://www.mmopowerlevel.net/powerlist.php?fid=688]wow power leveling[/url] have "toons" that are both Skinner, Herbalist and Skinner, Miner ... I think
the coin generated is a little better as a Miner (esp as you get occ. gem [url=http://www.mmopowerlevel.net/buy.php]wow gold[/url] drops in ore placements),
but if you choose a dark-elf as a race go herbalist as the starting area has no mining resources - there may be an equivalent horde race ! These
[url=http://www.mmopowerlevel.net/powerlist.php?fid=7422]aion power leveling[/url] flasks can only be only be used in Blades Edge Mountains
[url=http://www.mmopowerlevel.net/gamelist.php?fid=7656]aion gold[/url] and Gruul's Lair, and will save [url=http://www.mmopowerlevel.net]cheap wow gold
[/url] you hundreds of gold when raiding [url=http://www.mmopowerlevel.net]cheap wow power leveling[/url] that instance.
我来回复