哪位高手帮我运行程序加个边框

#include
#include
int main()
{
int a,b;
int x=1;
int y=1;
int v1=2;
int v2=2;
int top=0;
int bottom=10;
int right=0;
int left=60;
while(1)
{
x=x+v1;
y=y+v2;
system("cls");
for(a=0;a
printf("\n");
printf("|",x) ;
for(b=0;b
printf(" ");
printf("o\n");
if(x<=top || x>=bottom)
v1=-v1;
if(y<=right || y>=left)
v2=-v2;
}
return 0;
}
就是这个程序运行中,小球会在这个界限内运动,但我不会把这个边框画上线。哪位回画,教教我!谢谢

#include <stdio.h>
#include <stdlib.h>

void printTB(int r)
{
    for (int l = 0; l <= r; l++)
        printf("-");
    printf("\n");
}

/// @param r 右边结束位置
/// @param c 输出行数
void printLR(int r, int c)
{
    for (int a = 1; a <= c; a++)
    {
        printf("|");
        for (int b = 0; b <= r; b++)
            printf(" ");
        printf("|\n");
    }
}

int main()
{
    int a, b;
    int x = 1;
    int y = 1;
    int v1 = 2;
    int v2 = 2;
    int top = 0;
    int bottom = 10;
    int right = 0;
    int left = 60;

    while (1)
    {
        x = x + v1;
        y = y + v2;
        system("cls");

        printTB(left + 2); //输出顶部
        printLR(left, x);  //输出小球上部边框

        //输出小球行
        printf("|");
        for (b = 0; b < y-1; b++)
            printf(" ");
        printf("o");

        for (b = y; b <= left; b++)
            printf(" ");
        printf("|\n");
        
        printLR(left, bottom - x); //输出小球下部框
        printTB(left + 2); //输出底框

        if (x <= top || x >= bottom)
            v1 = -v1;
        if (y <= right || y >= left)
            v2 = -v2;
        _sleep(500); //暂停500ms
    }
    return 0;
}

img

请把程序填入 ’代码块‘ 中。