序列卷积
//-------------------------------------------------------------------------------------------------
//本程序可以实现两个任意长度序列的卷积
//====>序列 1:x[M]
//
序列 2:y[N]
// 只要在程序中改变 M、N、x[M]、y[n]的值,即可实现.
//
//长度为 M 的序列 x[]和长度为 N 的序列 y[],卷积 z[]的序列长度为 M+N-1.
//
//Date
//Author: SCJ
//-------------------------------------------------------------------------------------------------
: 2012-02-09
#include
#include
#define M 6 //卷积序列 x[]的长度
#define N 4 //卷积序列 y[]的长度
//---------------------------------------------------------------------------
//函数功能:
// 卷积函数的实现
// 对两个序列 x[]和 y[]进行卷积,z[]为卷积后所得序列
//--------------------------------------------------------------------------
void Juanji(int x[],int y[],int z[])
{
int i,j;
for (i=0;i=0 && i-j序列卷积
void OutputPoly(int array[],int x)
{
int i,j;
j=x-1;
for (i=0;i=0)
{
printf("+");
}
}
}
//----------------------------------------------------
//函数功能:
// 输出卷积后所得的序列
//----------------------------------------------------
void Output(int array[])
{
int i,j;
j=M+N-2;
printf("\n");
for (i=0;i=0)
{
printf("+");
}
}
printf("\n\n\n");
}
int main()
{
int x[M]={1,3,5,7,9,11},y[N]={2,4,6,8},z[M+N-1];
printf("\nThe first poly is:\n");
OutputPoly(x,M);
printf("\nThe second poly is:\n");
OutputPoly(y,N);
2 / 3
序列卷积
Juanji(x,y,z);
printf("\n\nThe result poly is:\n");
Output(z);
return 0;
}
3 / 3