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

熱點內容
資料庫是基於表格嗎 瀏覽:848
編程都學哪些 瀏覽:354
win10原文件被覆蓋怎麼恢復 瀏覽:243
如何調試表格數據 瀏覽:366
數據恢復下載哪個軟體好用 瀏覽:835
銀行app哪裡更新過期身份證 瀏覽:398
所有數據區是指什麼 瀏覽:858
香港的蘋果5c多少錢 瀏覽:513
win10nodejs環境失敗 瀏覽:862
新冠病毒最新數據在哪裡查看 瀏覽:515
iphone921不能imessage 瀏覽:449
恥辱2裝備升級 瀏覽:218
大學生投稿網站有哪些 瀏覽:595
qq空間朋友網入口在哪 瀏覽:211
多空下載教程 瀏覽:563
win10不能打開exe文件 瀏覽:571
發圖的網站都有什麼 瀏覽:551
有什麼好的定點的導航app 瀏覽:75
聯想電腦指紋登錄密碼忘記了怎麼辦 瀏覽:758
oracle操作系統版本 瀏覽:345

友情鏈接