左箭頭 三角形 + 大數n!

  • 165
  • 0
  • 2019-07-26

左箭頭 三角形

#include <stdio.h>

int main()
{
    int user=15;
    
    int row=1;
    int col=1;
    for (row=1;row<=(user*2-1);row++)
    {
        for (col=1;col<=(user);col++)
        {
            if (col==(user)||(user+1)-((user*2)-row)==col||(user+1)-(row)==col)
            {
                printf("*");
            }
            else
            {
                printf(" ");
            }
        }
        printf("\r\n");
    }
    
    
    return 0;
}
void CalN_Solution1(int n)
{
	int a[90000] = { 1, 0 }; //保存结果,包括中间结果
	int m = 0;
	for (; n; n--)   //依次乘以n, n-1, 1
	{
		int c = 0;  //进位值
		for (int i = 0; i <= m; i++) //中间结果乘以n
		{
			c += a[i] * n;   //先计算再考虑进位
			a[i] = c % 10;   //第i位的中间结果
			c /= 10;         //向上进位
		}
		for (; c; c /= 10)    //向上进位
			a[++m] = c % 10;
	}
	for (; m >= 0; m--) //打印结果
		cout << a[m];
	cout << endl;

}

int main(void)
{
	int n=10;
	cin >> n;
	CalN_Solution1(n);
	cin >> n;
	return 0;
}