#include<iostream>
using namespace std;

template<typename T>
class Carray
{
public:
    T add(T ary[],int n)
    {
      p=ary;
      size=n;
      T sum=0;
      for( int i=0; i<size; i++ )
        {
          sum += *(p+i);
        }
    return sum;
    }
private:
    T *p;
    int size;
};
int main()
{
    Carray<int> c1;
    int i_ary[5];
    cout<<"请输入5个整数："<<endl;
    for(int i=0;i<5;i++)
    {
      cin>>i_ary[i];
    }
    cout<<"i_sum="<<c1.add(i_ary,5)<<endl;
    Carray<double> c2;
    double d_ary[3];
    cout<<"请输入3个浮点数："<<endl;
    for(int i=0;i<3;i++)
    {
      cin>>d_ary[i];
    }
    cout<<"d_sum="<<c2.add(d_ary,3)<<endl;
    return 0;
}