1 #include <iostream> 2 using namespace std; 3 int gcd(int a, int b) 4 { 5 if (0 == a % b) 6 { 7 return b; 8 } 9 return gcd(b, a % b); 10 } 11 int gcdd(int* p, int len) 12 { 13 int* pp = new int[len]; 14 int res =0; 15 memcpy(pp, p, len * sizeof(int)); 16 for (int i = 1; i < len; i++) 17 { 18 *pp = gcd(*pp, *(pp+i)); 19 } 20 res = *pp; 21 delete [] pp; 22 return res; 23 }