#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
#include <time.h>
void HideCursor(int x)
{
CONSOLE_CURSOR_INFO cursor_info ={1,x};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
}
void GotoXY(int x, int y)
{
COORD pos;
pos.X=x-1;
pos.Y=y-1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void DrawRectangle(int x1,int y1,int x2,int y2)
{
int i;
for(i = x1;i<=x2;i=i+2)
{
GotoXY(i,y1);
printf("■");
GotoXY(i,y2);
printf("■");
}
for(i = y1;i<=y2;i=i+1)
{
GotoXY(x1,i);
printf("■");
GotoXY(x2,i);
printf("■");
}
}
void SetColor(int color)
{
HANDLE consolehwnd;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
consolehwnd = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(consolehwnd,&csbiInfo);
color = color + (csbiInfo.wAttributes&0xf0);
SetConsoleTextAttribute(consolehwnd,color);
}
void SetBKColor(int color)
{
HANDLE consolehwnd;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
consolehwnd = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(consolehwnd,&csbiInfo);
color = (color<<4) + (csbiInfo.wAttributes&0xf);
SetConsoleTextAttribute(consolehwnd,color);
}
void DrawPlan(int x, int y)
{
GotoXY(x, y);
printf(" ■■ ■■");
GotoXY(x, y + 1);
printf(" ■■■■ ■■■■");
GotoXY(x, y + 2);
printf(" ■■■■■■■■■■■");
GotoXY(x, y + 3);
printf(" ■■■■■■■■");
GotoXY(x, y + 4);
printf(" ■■■■■■");
GotoXY(x, y + 5);
printf(" ■■■");
GotoXY(x, y + 6);
printf(" ■");
}
int main()
{
int x1=10, y1=1, x2=x1+26+2, y2=y1+20;
int i;
char c;
int t=1,d=10;
int ys;
char input;
printf("输入y开始程序:\n");
scanf("%c",&input); //输入yes开始程序
if (input=='y')
{
srand(time(NULL)); //初始化随机数种子
ys=rand()%9+1; //a=rand()%(d-t)+t; 生成一个[t,d)区间内的整数
SetColor(ys);
SetBKColor(5);
system ("mode con cols=80 lines=22"); //设置窗口大小
HideCursor (0);
DrawPlan(10,6); //绘制爱心图形
DrawRectangle (x1,y1,x2,y2);
怎么让字母落下后那个💕不被覆盖,求大佬优化优化
你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答
本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。
因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。