导航:首页 > 编程知识 > gotoxy是哪个编程语言

gotoxy是哪个编程语言

发布时间:2025-01-23 06:29:47

A. C语言中有没有能返回上一行的控制符

用gotoxy函数可以让光标去任何位置!
wherex()和wherey()两个函数可以返回当前光标位置。
所在头文件:conio.h
函数原型:void gotoxy(int x,int y)
int wherex(void)
int wherey(void)
输入参数:x,y 为要移动的目的坐标位置
如:返回上一行开头:gotoxy(1,wherey()-1);

B. 如何实现c语言程序各颜色数字雨代码

#include<stdio.h>

#include<time.h>

#include<windows.h>

typedef struct

{

int x,y;

char ch;

}STU;

STU st[100];

//出现位置

void gotoxy(int x, int y)

{

HANDLE hout;

COORD pos;

pos.X = x;

pos.Y = y;

hout = GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleCursorPosition(hout, pos);

}

/*隐藏光标*/

void show_cursor(int hide)

{

CONSOLE_CURSOR_INFO cciCursor;

HANDLE hout;

hout = GetStdHandle(STD_OUTPUT_HANDLE);

if(GetConsoleCursorInfo(hout, &cciCursor))

{

cciCursor.bVisible = hide;

SetConsoleCursorInfo(hout, &cciCursor);

}

}

/*设置颜色*/

void set_color(int color)

{

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);

}

main()

{

int i,j;

show_cursor(0);

srand(time(NULL));

//初始化结构体

for (i=0;i<100;i++)

{

st[i].x = rand()%80;

st[i].y = rand()%20;

st[i].ch = rand()%(49-47)+48;

}

while (1)

{

for (i=0;i<100;i++)

{

gotoxy(st[i].x,st[i].y);

set_color(0x2);//最先出现的颜色;

putchar(st[i].ch);

gotoxy(st[i].x,st[i].y-5);

putchar(' ');

st[i].y++;

st[i].ch = rand()%(49-47)+48;

if (st[i].y-5>=18)

{

gotoxy(st[i].x,st[i].y-1);

putchar(' ');

gotoxy(st[i].x,st[i].y-2);

putchar(' ');

gotoxy(st[i].x,st[i].y-3);

putchar(' ');

gotoxy(st[i].x,st[i].y-4);

putchar(' ');

gotoxy(st[i].x,st[i].y-4);

putchar(' ');

}

if (st[i].y > 23)

{

st[i].x = rand()%80;

st[i].y = rand()%20;

}

gotoxy(st[i].x,st[i].y);

set_color(0xA);//由前一个颜色渐变成的颜色

putchar(st[i].ch);

}

Sleep(120);

}

}

color(0);printf("黑色 ");color(1);printf("蓝色 ");color(2);printf("绿色 ");color(3);printf("湖蓝色 ");color(4);printf("红色 ");color(5);printf("紫色 ");color(6);printf("黄色 ");color(7);printf("白色 ");color(8);printf("灰色 ");color(9);printf("淡蓝色 ");color(10);printf("淡绿色 ");color(11);printf("淡浅绿色 ");color(12);printf("淡红色 ");color(13);printf("淡紫色 ");color(14);printf("淡黄色 ");color(15);printf("亮白色 ")

几个基本的颜色;

阅读全文

与gotoxy是哪个编程语言相关的资料

热点内容
免费的电脑文件打印软件 浏览:262
pdf文件名长度有限制吗 浏览:813
暗黑破坏神2atma505图文教程 浏览:373
苹果手机怎么文件形式重命名 浏览:83
沈阳如何用app办理个人养老 浏览:698
ps键盘教程 浏览:145
四个excel文件怎么合并 浏览:477
如何将手机视频导入文件管理 浏览:381
cfile读取多个文件 浏览:138
存放的文件有哪些 浏览:582
机器人编程课推广文案怎么写 浏览:950
更新爱思配置文件失败 浏览:420
邮箱文件过期怎么办 浏览:914
flashcs5视频教程下载 浏览:626
淘宝详情页源代码 浏览:239
查询车在哪里的app 浏览:905
苹果id怎么怎么输入代码是什么格式 浏览:861
游戏原声带放哪个文件夹 浏览:275
cad图形文件咋画 浏览:226
ios下载美区appstore 浏览:923

友情链接