淘先锋技术网

首页 1 2 3 4 5 6 7
#include<stdio.h>
void exchange(int arr1[], int arr2[], int n)
{
	int i = 0;
	for (i = 0; i < n; i++)
	{
		arr1[i] = arr2[i];
	}
}
void print(int arr1[10], int n)
{
	int i = 0;
	for (i = 0; i < n; i++)
	{
		printf("%d ", arr1[i]);
	}
	printf("\n");
}
int main()
{
	int i = 0;
	int n = 0;
	int arr1[11] = { 0 };
	int arr2[11] = { 0 };
	for (n = 1; n < 11; n++)
	{
		if (n < 3)
		{
			for (i = 0; i < n; i++)
			{
				arr1[i] = 1;
			}
			print(arr1, n);
		}
		else
		{
			for (i = 0; i < n; i++)
			{
				if (i == 0 || i == (n - 1))
				{
					arr2[i] = 1;
				}
				else
				{
					arr2[i] = arr1[i - 1] + arr1[i];
				}
			}
			exchange(arr1, arr2, n);
			print(arr1, n);
		}
	}
	return 0;
}