gpt4 book ai didi

c++ - c++中的 anchor gotoxy

转载 作者:太空宇宙 更新时间:2023-11-04 13:41:15 26 4
gpt4 key购买 nike

我的身材呈“Σ”形。问题是我必须从左上角而不是中间缩放它,这个符号的对角线连接的地方。

如果有人愿意分享任何关于如何改变它的 anchor 以扩大或缩小它的边的技巧,我将不胜感激。我考虑了将近一周,但不知道要更改什么。

void figure(int &x1, int &x, int &y1, int &y, int &side, char &a, char &key) 
{
system("cls");

x1 = x; y1 = y;
gotoxy(x1, y1);
for (int i = 1; i <= side+ 10; i++) // upper figure edge
{
cout << a;
}
for (int i = 1; i <= side; i++) // diagonal edge
{
y1++;
x1 = x + (i <= side / 2 ? i : (side - i + 1)) ;
gotoxy(x1, y1);
cout << a;
x1 = x;
}

y1++;
gotoxy(x1, y1);
for (int i = 1; i <= side + 10; i++) // bottom figure edge
cout << a;
key = getch();
}



void enlarge_reduce(char &key, const int &console_size_x, const int &console_size_y, int &side, int &x, int &y, int &x1, int &y1) //enlarging and reducing figure size
{
switch (key)
{
case '+': // figure enlarge

if (side <= (console_size_y <= console_size_x ? console_size_y - 4 : console_size_x - 4))
{
side += 2;
--x;
--y;
}
break;

case '-': // reduce figure
if (side > 4)
{
side -= 2;
++x; ++y;
}
break;
}
}

最佳答案

您的 figure() 函数使用左上角作为 anchor ,而不是中间。您的 enlarge_reduce() 函数正在移动左上角。

关于c++ - c++中的 anchor gotoxy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27590084/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com