#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int i;
int j;
int size;
int end;
int begin;
int start;
int lengthWord;
int counter1;
int counter2;
int counter3;
int counter5;
int maxindex;
vector<string>sorting;
vector<string>smalltogreat;
string input;
string temp;
cout<<"Enter a line of text."<<endl;
getline(cin, input);
input = " " + input;
size = 0;
while(size < input.size())
{
i = 0;
j = 0;
end = 0;
begin = 0;
while(input[end] == ' ')
{
end = end + 1;
begin = end;
start = begin;
}
while(input[begin] != ' ')
{
begin = begin + 1;
end = begin;
}
lengthWord = end - start;
sorting.resize(j+1);
sorting.at(j) = input.substr(start, lengthWord);
size++;
j = j++;
}
for(counter1=0; counter1 < sorting.size(); counter1++)
{
cout<<sorting.at(counter1)<<endl;
}
for(counter3=1; counter3 <= sorting.size(); counter3++)
{
for(counter2=0; counter2 < sorting.size(); counter2++)
{
maxindex = 0;
if (sorting.at(maxindex) < sorting.at(counter2))
maxindex = counter2;
}
temp = sorting.at(sorting.size()-1);
sorting.at(sorting.size()-1) = sorting.at(maxindex);
sorting.at(maxindex) = temp;
smalltogreat.resize(sorting.size());
smalltogreat.at(smalltogreat.size()-counter3) = sorting.at(sorting.size()-1);
sorting.pop_back();
}
for(counter5=0; counter5 < smalltogreat.size(); counter5++)
{
if(smalltogreat.at(counter5)==smalltogreat.at(counter5+1))
cout<<"At least one word appears twice or more in the input."<<endl;
else
cout<<"There are no duplicate words in the input."<<endl;
}
return 0;
}