-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
62 lines (56 loc) · 1.27 KB
/
test.cpp
File metadata and controls
62 lines (56 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>
#include <string>
using namespace std;
bool search(string str[],string s,int length)
{
for (size_t i = 0; i < length; i++)
{
if(str[i]==s)
{
return true;
}
}
return false;
}
int main(int argc, char const *argv[])
{
int t;
cin>>t;
int length=0;
for (size_t z = 0; z < t; z++)
{
int n;
cin>>n;
string str[100000];
for (size_t i = 0; i < n; i++)
{
string s;
cin>>s;
if(!search(str,s,length))
{
str[length]=s;
length++;
int first=length-1;
for (int j = length-1; j >= 0; j--)
{
//cout<<j<<" ";
if(str[first]<str[j])
{
string temp=str[first];
str[first]=str[j];
str[j]=temp;
first=j;
}
}
}
}
for (size_t j = 0; j < length; j++)
{
if(str[j]!="")
{
cout<<str[j]<<endl;
}
}
}
return 0;
}