void printSanJiao()
{
//思路
//1.头尾都是1
//2.每次都要保存当前列表的数据(以便计算下个列表的参数)
//3.出头尾外的值 是 上一个列表中当前下标 上一个列表中当前下标 -1 之和
//用到 二维数组 ,字符串相加
vector<vector<int>> vecList = {};
int count = 5;
for (int i = 0; i <= count; i++)
{
vector<int> vec = {};
for (int j = 0; j <= i;j++)
{
if (j==0||j==i)
{
vec.push_back(1);
}
else
{
int forwardSize = vecList.size()-1;
if ((vecList[forwardSize][j-1]) && (vecList[forwardSize][j]))
{
int nums = vecList[forwardSize][j – 1] + vecList[forwardSize][j];
vec.push_back(nums);
}
}
}
vecList.push_back(vec);
}
//打印信息
for (vector<vector<int>>::iterator vecit = vecList.begin(); vecit != vecList.end();vecit++)
{
string str = “”;
for (vector<int>::iterator it = (*vecit).begin(); it != (*vecit).end();it++)
{
char printchar[512] = “”;
sprintf_s(printchar, “%d “, *it);
str = str +printchar;
}
str = str + “\n”;
printf(str.c_str());
}
system(“pause”);
}