c++ 如何让输出居中(x,y坐标都要在正中)?

我想做一个程序,但输出空格居中太麻烦了,想要让输出自动居中!

include<bits/stdc++.h>
#include<windows.h>
using namespace std;
#ifndef NRZ
#define NRZ
void goxy(int x, int y)
{
COORD p;
p.X = x - 1;
p.Y = y - 1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), p);
}
void dx(int x,int y)
{
char a[50]="mode con lines= cols= ";
if(x>=10)
{
a[17]=char(x%10);
a[16]=char(x/10);
}
else
a[16]=char(x);
//a[23]
if(y<10)
{
a[23]=char(y);
}
else
{
if(y>=100)
{
a[23]=char(y/100);
a[24]=char(y/10%10);
a[25]=(char(y%10));
}
else
{
a[23]=char(y/10);
a[24]=char(y%10);
}
}
system(a);
}
#endif