请教清屏后光标问题

[复制链接]
查看11 | 回复3 | 2021-1-27 06:52:08 | 显示全部楼层 |阅读模式
#include
usingnamespacestd;
#include
#include
#include

constintCOLUMN=3;
constintROW=3;
voiddefine_world(charworld[][COLUMN],intROW);
//precondition:ROWandCOLUMNofamatrixwithallcharactersequal''
//postcondition:returnanewworldfilledwith''or'*',it'suptoyoutodeterminewhichoneis'*'
//byenterspacewhenasked
voidgeneration(charworld[][COLUMN],intROW);
//precondition:worldhasbeendefined.
//postcondition:giveanewworldafteronceevolution.
voidsurround(charworld[][COLUMN],intROW,inti,intj);
//precondition:world
//postcondition:anewworldgeneralizedbyrule.iftherearemorethanthanthreecells
//inthesurroundingeightpositions,itwilldieofcrowdness.
//iftherearelessthantwocells,itwilldiesofloneliness
//ifthereareexactlythreecellsaroundit,acellwillborn.
voidnew_line();
//Toreadthereaminletters
intmain()
{
charworld[ROW][COLUMN];
charspace;
define_world(world,ROW);
cin.get(space);
new_line();
if(space!='')
return0;
do
{
system("cls");
generation(world,ROW);
cin.get(space);
new_line();
}while(space=='');
cout -->
回复

使用道具 举报

千问 | 2021-1-27 06:52:08 | 显示全部楼层
这个是还没写完的程序,但是清屏部分的已经完成了,不过中间出现了点问题。在清屏后,输出一个空格,按下回车后。光标就直接跳过了三行,到第四行去了,请问这是为什么呢?
回复

使用道具 举报

千问 | 2021-1-27 06:52:08 | 显示全部楼层
求指点啊,各位
回复

使用道具 举报

千问 | 2021-1-27 06:52:08 | 显示全部楼层
仅供参考#include
#include
voidConPrint(char*CharBuffer,intlen);
voidConPrintAt(intx,inty,char*CharBuffer,intlen);
voidgotoXY(intx,inty);
voidClearConsole(void);
voidClearConsoleToColors(intForgC,intBackC);
voidSetColorAndBackground(intForgC,intBackC);
voidSetColor(intForgC);
voidHideTheCursor(void);
voidShowTheCursor(void);
intmain(intargc,char*argv[])
{
HideTheCursor();
ClearConsoleToColors(15,1);
ClearConsole();
gotoXY(1,1);
SetColor(14);
printf("Thisisatest...\n");
Sleep(5000);
ShowTheCursor();
SetColorAndBackground(15,12);
ConPrint("Thisisalsoatest...\n",23);
SetColorAndBackground(1,7);
ConPrintAt(22,15,"Thisisalsoatest...\n",23);
gotoXY(0,24);
SetColorAndBackground(7,1);
return0;
}
//Thiswillcleartheconsolewhilesettingtheforgroundand
//backgroundcolors.
voidClearConsoleToColors(intForgC,intBackC)
{
WORDwColor=((BackC&0x0F)
Linux下使用NCURSES库。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行