導航:首頁 > 編程知識 > 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是哪個編程語言相關的資料

熱點內容
沒有網路怎麼定位 瀏覽:972
剪切到優盤文件找不到了 瀏覽:764
電腦管家的文件名 瀏覽:910
如何將掃描文件轉換為電子版 瀏覽:4
u盤的h246文件怎麼播放 瀏覽:203
如何用阿里雲伺服器學習資料庫 瀏覽:84
華為文件管理找不到下載文件 瀏覽:409
word模板dot的使用 瀏覽:466
春節車找人app哪個好 瀏覽:618
文件管理電腦找不到了怎麼辦 瀏覽:516
如何改變app圖標圖片 瀏覽:767
什麼是大數據結構的最低層 瀏覽:575
pdf文件給對方後期改密碼收回 瀏覽:295
word2010怎麼畫箭頭 瀏覽:184
win10的自動備份文件在哪個目錄 瀏覽:843
文件夾打包成jar 瀏覽:456
卸載魯大師找不到文件 瀏覽:173
匯編程序不知道哪裡有錯誤 瀏覽:821
ai視頻教程cs5 瀏覽:379
億林網路怎麼樣 瀏覽:102

友情鏈接