找重复的元素
#include <iostream>using namespace std;template<typename T,int index>struct SumArr{static int GetValue(T* arr){return arr[index] + SumArr<T,index-1>::GetValue(arr);}};template<typename T>struct SumArr<T,0>{static int GetValue(T* arr){return arr[0];}};int main(void){ int arry[11] = {1,2,3,4,5,6,7,8,9,10,2}; printf("%d",SumArr<int,10>::GetValue(arry) - 11*5); getchar();return 0;}
?
?
?
?