⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 序列卷积运算之c语言实现.txt

📁 c语言的一些常见的算法以及思考和改进的文章,写的很不错,花费了很大的精力从网络了搜罗的,希望大家喜欢.
💻 TXT
字号:
序列卷积运算之C语言实现[原创] 
       设x是有n+1个样值的有限序列,y是有m+1个样值的有限序列,则二者的卷积z有n+m+1个样值,并且有zt=∑xpyt-p,t=0,1,...,n+m;p=0,1,...,n。当p<0或p>n时,有xp=0;当t-p<0或t-p>m时,有yt-p=0。

      代码如下,简单模拟:

#define N 6
#define M 8
#define K 10

#i nclude <conio.h>
#i nclude <stdlib.h>

void initial(int array[],int n)
{
  while(n>=0)
    array[n--]=random(K);
}

void juanji(int x[],int y[],int z[])
{
  int i,j;
  for(i=0;i<=N+M;i++)
  {
     int t=0;
     for(j=0;j<=N;j++)
       if(i-j>=0&&i-j<=M)
           t+=x[j]*y[i-j];
     z[i]=t;
  }
}

void output(int array[],int n)
{
  int i;
  for(i=0;i<=n;i++)
    printf("%4d",array[i]);
  printf("\n\n");
}

void main()
{
  int x[N+1],y[M+1],z[N+M+1];
  initial(x,N);
  initial(y,M);
  juanji(x,y,z);
  output(x,N);
  output(y,M);
  output(z,N+M);
}
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -