标签:200 int cin ++ GoodCopy Print goodcopy 034
1 #include <iostream> 2 using namespace std; 3 4 5 template <class T> 6 struct GoodCopy { 7 // 在此处补充你的代码 8 void operator()(T* p,T* q,T* r){ 9 int n = q - p; 10 while(n + 1){ 11 *(r + n) = *q; 12 -- n; 13 -- q; 14 } 15 } 16 }; 17 18 int a[200]; 19 int b[200]; 20 string c[200]; 21 string d[200]; 22 23 template <class T> 24 void Print(T s,T e) { 25 for(; s != e; ++s) 26 cout << * s << ","; 27 cout << endl; 28 } 29 30 int main() 31 { 32 int t; 33 cin >> t; 34 while( t -- ) { 35 int m ; 36 cin >> m; 37 for(int i = 0;i < m; ++i) 38 cin >> a[i]; 39 GoodCopy<int>()(a,a+m,b); 40 Print(b,b+m); 41 GoodCopy<int>()(a,a+m,a+m/2); 42 Print(a+m/2,a+m/2 + m); 43 44 for(int i = 0;i < m; ++i) 45 cin >> c[i]; 46 GoodCopy<string>()(c,c+m,d); 47 Print(c,c+m); 48 GoodCopy<string>()(c,c+m,c+m/2); 49 Print(c+m/2,c+m/2 + m); 50 } 51 return 0; 52 }
标签:200,int,cin,++,GoodCopy,Print,goodcopy,034 来源: https://www.cnblogs.com/balabalabubalabala/p/16677901.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。