gcd.c

来自「Matlab时频分析工具箱,希望能对大家有所帮助啊」· C语言 代码 · 共 56 行

C
56
字号
#include "config.h"#ifdef HAVE_COMPLEX_H#include <complex.h>#endif#include <stdlib.h>#include <stdio.h>#include <math.h>void print_z(const int N, ltfat_complex *p){  int i;    for(i=0;i<N;i++)  {#ifdef HAVE_COMPLEX_H    printf("%.16lf  %.16lf\n",creal(p[i]),cimag(p[i]));#else    printf("%.16lf  %.16lf\n",p[i][0],p[i][1]);#endif  }  fflush(NULL);  }/* Extended Euclid algorithm. */int gcd (const int a, const int b, int *r, int *s ){  int a1 = a;  int b1 = b;  int a2 = 1;  int b2 = 0;  int a3 = 0;  int b3 = 1;  int c, d;  while ( b1 != 0 )   {      d=a1/b1;      c = a1;      a1 = b1;      b1 = c-d*b1;      c = a2;      a2 = b2;      b2 = c-d*b2;            c = a3;      a3 = b3;      b3 = c-d*b3;        }     *r=a2;  *s=a3;  return a1;}

⌨️ 快捷键说明

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