#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
bool cmp(double a, double b)
{
return a > b;
}
template <class T>
class Array
{
public:
vector<T> v_;
Array(int l = 0)
{
v_.resize(l);
}
int size()
{
return v_.size();
}
void put(int n)
{
int num = n;
if(v_.size() < n)
num = v_.size();
sort(v_.begin(), v_.end(), cmp);
for(int i = 0; i < num; i++)
{
if(i != 0)
cout << " ";
cout << v_[i];
}
cout << endl;
}
T &operator [] (const int i)
{
return v_[i];
}
~Array()
{
v_.clear();
}
};
int main()
{
int cases, len;
cin >> cases;
for(int ca = 1; ca <= cases; ca++)
{
cin >> len;
if(ca % 3 == 0)
{
Array<char> chr_arr(len);
for(int i = 0; i < chr_arr.size(); i++)
cin >> chr_arr[i];
chr_arr.put(10);
}
if(ca % 3 == 1)
{
Array<int> int_arr(len);
for(int i = 0; i < int_arr.size(); i++)
cin >> int_arr[i];
int_arr.put(10);
}
if(ca % 3 == 2)
{
Array<double> dbl_arr(len);
for(int i = 0; i < dbl_arr.size(); i++)
cin >> dbl_arr[i];
dbl_arr.put(10);
}
}
}
oj数组模板类Array
最新推荐文章于 2022-05-19 11:31:14 发布